WYB
2021-03-22 91b8cdad021ab052e4991f3d41834a6f0ddc36b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using JiepeiWMS.Common;
using JiepeiWMS.Controllers;
using JiepeiWMS.IServices;
using JiepeiWMS.Model.Models;
using Moq;
using Xunit;
using System;
using Microsoft.Extensions.Logging;
using Autofac;
 
namespace JiepeiWMS.Tests
{
    public class BlogController_Should
    {
        Mock<IBlogArticleServices> mockBlogSev = new Mock<IBlogArticleServices>();
        Mock<IRedisCacheManager> mockRedisMag = new Mock<IRedisCacheManager>();
        Mock<ILogger<BlogController>> mockLogger = new Mock<ILogger<BlogController>>();
        BlogController blogController;
 
        private IBlogArticleServices blogArticleServices;
        DI_Test dI_Test = new DI_Test();
 
 
 
        public BlogController_Should()
        {
            mockBlogSev.Setup(r => r.Query());
 
 
            var container = dI_Test.DICollections();
            blogArticleServices = container.Resolve<IBlogArticleServices>();
            //blogController = new BlogController(blogArticleServices, mockLogger.Object);
        }
 
        [Fact]
        public void TestEntity()
        {
            BlogArticle blogArticle = new BlogArticle();
 
            Assert.True(blogArticle.bID >= 0);
        }
        [Fact]
        public async void GetBlogsTest()
        {
            object blogs =await blogController.Get(1);
 
            Assert.NotNull(blogs);
        }
 
        [Fact]
        public async void PostTest()
        {
            BlogArticle blogArticle = new BlogArticle()
            {
                bCreateTime = DateTime.Now,
                bUpdateTime = DateTime.Now,
                btitle = "xuint :test controller addEntity",
 
            };
 
            var res = await blogController.Post(blogArticle);
 
            Assert.True(res.success);
 
            var data = res.response;
 
            Assert.NotNull(data);
        }
    }
}