BootstrapAdmin/UnitTest/Bootstrap.DataAccess/SQLServer/TracesTest.cs

36 lines
1.8 KiB
C#
Raw Normal View History

using Longbow.Data;
using Longbow.Web.Mvc;
2019-05-01 16:46:24 +08:00
using System;
using Xunit;
2019-05-01 16:46:24 +08:00
namespace Bootstrap.DataAccess.SqlServer
2019-05-01 16:46:24 +08:00
{
[Collection("SQLServerContext")]
public class TracesTest
{
[Fact]
public void Retrieves_Ok()
{
var log = new Trace()
{
UserName = "UnitTest",
Browser = "UnitTest",
City = "本地连接",
OS = "UnitTest",
Ip = "::1",
2019-05-01 16:46:24 +08:00
LogTime = DateTime.Now,
RequestUrl = "~/Home/Index"
};
2019-06-01 16:57:33 +08:00
Assert.True(DbContextManager.Create<Trace>().Save(log));
Assert.NotNull(TraceHelper.Retrieves(new PaginationOption() { Limit = 20, Offset = 0, Order = "desc", Sort = "LogTime" }, null, null, null).Items);
Assert.NotNull(TraceHelper.Retrieves(new PaginationOption() { Limit = 20, Offset = 0, Order = "desc", Sort = "IP" }, null, null, null).Items);
Assert.NotNull(TraceHelper.Retrieves(new PaginationOption() { Limit = 20, Offset = 0, Order = "desc", Sort = "UserName" }, null, null, null).Items);
Assert.NotNull(TraceHelper.Retrieves(new PaginationOption() { Limit = 20, Offset = 0, Order = "desc", Sort = "City" }, null, null, null).Items);
Assert.NotNull(TraceHelper.Retrieves(new PaginationOption() { Limit = 20, Offset = 0, Order = "desc", Sort = "Browser" }, null, null, null).Items);
Assert.NotNull(TraceHelper.Retrieves(new PaginationOption() { Limit = 20, Offset = 0, Order = "desc", Sort = "OS" }, null, null, null).Items);
Assert.NotNull(TraceHelper.Retrieves(new PaginationOption() { Limit = 20, Offset = 0, Order = "desc", Sort = "RequestUrl" }, null, null, null).Items);
Assert.NotEmpty(TraceHelper.RetrieveAll(null, null, null));
2019-05-01 16:46:24 +08:00
}
}
}