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
71
72
73
74
75
76
77
78
79
80
81
using JiepeiWMS.Model.Models;
using Xunit;
using System;
using System.Linq;
using Autofac;
using JiepeiWMS.IRepository.Base;
 
namespace JiepeiWMS.Tests
{
    public class Repository_Base_Should
    {
        private IBaseRepository<BlogArticle> baseRepository;
        DI_Test dI_Test = new DI_Test();
 
        public Repository_Base_Should()
        {
 
            var container = dI_Test.DICollections();
 
            baseRepository = container.Resolve<IBaseRepository<BlogArticle>>();
 
            //DbContext.Init(BaseDBConfig.ConnectionString,(DbType)BaseDBConfig.DbType);
        }
 
 
        [Fact]
        public async void Get_Blogs_Test()
        {
            var data = await baseRepository.Query();
 
            Assert.NotNull(data);
        }
 
        [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 repositoryBase add blog",
            };
 
            var BId = await baseRepository.Add(blogArticle);
            Assert.True(BId > 0);
        }
 
 
        [Fact]
        public async void Update_Blog_Test()
        {
            var IsUpd = false;
            var updateModel = (await baseRepository.Query(d => d.btitle == "xuint test title")).FirstOrDefault();
 
            Assert.NotNull(updateModel);
 
            updateModel.bcontent = "xuint: test repositoryBase content update";
            updateModel.bCreateTime = DateTime.Now;
            updateModel.bUpdateTime = DateTime.Now;
 
            IsUpd = await baseRepository.Update(updateModel);
 
            Assert.True(IsUpd);
        }
 
        [Fact]
        public async void Delete_Blog_Test()
        {
            var IsDel = false;
            var deleteModel = (await baseRepository.Query(d => d.btitle == "xuint test title")).FirstOrDefault();
 
            Assert.NotNull(deleteModel);
 
            IsDel = await baseRepository.Delete(deleteModel);
 
            Assert.True(IsDel);
        }
    }
}