예제 #1
0
        public async Task GetAuthorsTest()
        {
            var bookTypes = new List <BookType>
            {
                new BookType()
                {
                    ID          = default(Guid),
                    Discription = "Discription 1"
                },
                new BookType()
                {
                    ID          = default(Guid),
                    Discription = "Discription 2"
                }
            };


            var fakeRepositoryMock = new Mock <IBookTypeRepository>();

            fakeRepositoryMock.Setup(x => x.getList()).ReturnsAsync(bookTypes);
            var service = new BookTypeService(fakeRepositoryMock.Object);

            var result = await service.GetList();

            Assert.Collection(result, bookType =>
            {
                Assert.Equal("Discription 1", bookType.Discription);
            },
                              bookType =>
            {
                Assert.Equal("Discription 2", bookType.Discription);
            });
        }
예제 #2
0
        public async Task AddTest()
        {
            var fakeRepository = Mock.Of <IBookTypeRepository>();
            var service        = new BookTypeService(fakeRepository);
            var bookType       = new BookType()
            {
                ID          = default(Guid),
                Discription = "Discription 1"
            };

            service.Create(bookType);
        }
예제 #3
0
        public async Task SearchTest()
        {
            var bookType = new BookType
            {
                ID          = default(Guid),
                Discription = "Discription 1"
            };

            var fakeRepositoryMock = new Mock <IBookTypeRepository>();

            fakeRepositoryMock.Setup(x => x.Find(It.IsAny <Guid>())).Returns(bookType);


            var service = new BookTypeService(fakeRepositoryMock.Object);

            var result = service.Get(default(Guid));

            Assert.Equal("Discription 1", result.Discription);
        }
예제 #4
0
 public BookTypeController(BookTypeService bookTypeService)
 {
     _bookTypeService = bookTypeService;
 }
예제 #5
0
 /// <summary>
 /// 获取图书类型对象的列表
 /// </summary>
 /// <returns> List<BookType> </returns>
 public static List <BookType> GetBTlist()
 {
     return(BookTypeService.GetBookTypeList());
 }