init
This commit is contained in:
74
DouyinApi.Tests/Service_Test/BlogArticleService_Should.cs
Normal file
74
DouyinApi.Tests/Service_Test/BlogArticleService_Should.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using DouyinApi.IServices;
|
||||
using DouyinApi.Model.Models;
|
||||
using Xunit;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Autofac;
|
||||
|
||||
namespace DouyinApi.Tests
|
||||
{
|
||||
public class BlogArticleService_Should
|
||||
{
|
||||
|
||||
private IBlogArticleServices blogArticleServices;
|
||||
DI_Test dI_Test = new DI_Test();
|
||||
|
||||
|
||||
public BlogArticleService_Should()
|
||||
{
|
||||
//mockBlogRep.Setup(r => r.Query());
|
||||
|
||||
var container = dI_Test.DICollections();
|
||||
|
||||
blogArticleServices = container.Resolve<IBlogArticleServices>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void BlogArticleServices_Test()
|
||||
{
|
||||
Assert.NotNull(blogArticleServices);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async void Get_Blogs_Test()
|
||||
{
|
||||
var data = await blogArticleServices.GetBlogs();
|
||||
|
||||
Assert.True(data.Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Add_Blog_Test()
|
||||
{
|
||||
BlogArticle blogArticle = new BlogArticle()
|
||||
{
|
||||
bCreateTime = DateTime.Now,
|
||||
bUpdateTime = DateTime.Now,
|
||||
btitle = "xuint test title",
|
||||
bcontent = "xuint test content",
|
||||
bsubmitter = "xuint test submitter",
|
||||
};
|
||||
|
||||
var BId = await blogArticleServices.Add(blogArticle);
|
||||
|
||||
Assert.True(BId > 0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Delete_Blog_Test()
|
||||
{
|
||||
Add_Blog_Test();
|
||||
|
||||
var deleteModel = (await blogArticleServices.Query(d => d.btitle == "xuint test title")).FirstOrDefault();
|
||||
|
||||
Assert.NotNull(deleteModel);
|
||||
|
||||
var IsDel = await blogArticleServices.Delete(deleteModel);
|
||||
|
||||
Assert.True(IsDel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user