예제 #1
0
        public void RemoveBook()
        {
            var book = BookControllerTestHelper.AddOneBook(bookRepository);

            controller
            .Calling(c => c.RemoveBook(book.Id))
            .ShouldReturn()
            .Ok();

            var bookResult = bookRepository.GetById(book.Id);

            Assert.IsNull(bookResult);
        }
예제 #2
0
        public void BookListWithDefaultQuery()
        {
            var book = BookControllerTestHelper.AddOneBook(bookRepository);

            controller
            .Calling(c => c.BookList(1, 1))
            .ShouldReturn()
            .Ok(result => result
                .WithModelOfType <ListDTO <List <Book> > >()
                .Passing((model) =>
            {
                Assert.AreEqual(model.Data.Count, 1);

                var bookResult = bookRepository.GetById(model.Data[0].Id);

                Assert.IsNotNull(bookResult);
                Assert.AreEqual(bookResult.Title, "Władca Pierścieni: Drużyna Pierścienia");
            }
                         ));
        }
예제 #3
0
        public void UpdateBookWithBasicData()
        {
            var book = BookControllerTestHelper.AddOneBook(bookRepository);

            var title = "Test Book";

            var bookUpdateIn = new BookUpdateIn
            {
                Title = title
            };

            controller
            .Calling(c => c.UpdateBook(book.Id, bookUpdateIn))
            .ShouldReturn()
            .Ok();

            var bookResult = bookRepository.GetById(book.Id);

            Assert.AreEqual(bookResult.Title, title);
        }