コード例 #1
0
        public async Task Asking_the_controller_for_an_existing_book_will_return_200_OK()
        {
            const string isbn = "1234";
            var          book = new Book();

            _serviceMock.GetByIsbn(isbn).Returns(Task.FromResult(book));

            var result = await _subject.GetBook(isbn);

            var okResult = Assert.IsType <OkObjectResult>(result);
            var model    = Assert.IsAssignableFrom <Book>(okResult.Value);

            Assert.Same(book, model);
        }
コード例 #2
0
        public void Ensure_Book_Exists()
        {
            _bookService.Setup(s => s.GetById(It.IsAny <Guid>())).Returns(new Book());

            _categoryRepository.Setup(s => s.GetById(It.IsAny <Guid>())).Returns(new Category());

            var service = new BookApiController(_bookService.Object);

            var response = service.GetBook(Guid.NewGuid().ToString()).Result;

            Assert.Equal(StatusCodes.Status200OK, response.Code);
        }