BootstrapAdmin/UnitTest/Bootstrap.DataAccess/LogsTest.cs

32 lines
1.3 KiB
C#
Raw Normal View History

using Longbow.Web.Mvc;
using Xunit;
namespace Bootstrap.DataAccess.SqlServer
{
[Collection("SQLServerContext")]
public class LogsTest
{
[Fact]
public void Retrieves_Ok()
{
var log = new Log()
{
UserName = "UnitTest",
Browser = "UnitTest",
City = "本地连接",
OS = "UnitTest",
Ip = "::1",
CRUD = "UnitTest",
RequestUrl = "~/Home/Index"
};
2019-06-01 16:57:33 +08:00
Assert.True(LogHelper.Save(log));
Assert.NotNull(LogHelper.RetrievePages(new PaginationOption() { Limit = 20, Sort = "LogTime", Order = "desc" }, null, null, null));
Assert.NotNull(LogHelper.RetrievePages(new PaginationOption() { Limit = 20, Sort = "CRUD", Order = "desc" }, null, null, null));
Assert.NotNull(LogHelper.RetrievePages(new PaginationOption() { Limit = 20, Sort = "UserName", Order = "desc" }, null, null, null));
Assert.NotNull(LogHelper.RetrievePages(new PaginationOption() { Limit = 20, Sort = "Ip", Order = "desc" }, null, null, null));
Assert.NotNull(LogHelper.RetrievePages(new PaginationOption() { Limit = 20, Sort = "RequestUrl", Order = "desc" }, null, null, null));
Assert.NotEmpty(LogHelper.RetrieveAll(null, null, null));
}
}
}