예제 #1
0
        public void Create_WhenInvokedWithBook_ThenShouldAddNewBook()
        {
            // Arrange
            var catalog = new Catalog();

            // Act
            catalog.Create(BookStub.Object);

            // Assert
            catalog.Retrieve(BookStub.Object.Isbn).ShouldBeEquivalentTo(BookStub.Object);
        }
예제 #2
0
        public void Delete_WhenInvokedWithExistingIsbn_ThenShouldRemoveMatchingBookAndReturnTrue()
        {
            // Arrange
            var catalog = new Catalog();
            catalog.Create(BookStub.Object);
            var book = catalog.Retrieve(BookStub.Object.Isbn);

            // Act
            var result = catalog.Delete(BookStub.Object.Isbn);

            // Assert
            catalog.RetrieveAll().Should().NotContain(book);
            result.Should().BeTrue();
        }
예제 #3
0
        public void Update_WhenInvokedWithExistingBook_ThenShouldUpdateMatchingBookAndReturnTrue()
        {
            // Arrange
            var catalog = new Catalog();
            catalog.Create(BookStub.Object);
            var book = catalog.Retrieve(BookStub.Object.Isbn);

            // Act
            book.InStock = BookStub.Object.InStock = false;
            var result = catalog.Update(book);

            // Assert
            book.ShouldBeEquivalentTo(catalog.Retrieve(BookStub.Object.Isbn));
            result.Should().BeTrue();
        }
예제 #4
0
        public void Retrieve_WhenInvokedWithExistingIsbn_ThenShouldReturnMatchingBook()
        {
            // Arrange
            var catalog = new Catalog();
            catalog.Create(BookStub.Object);

            // Act
            var book = catalog.Retrieve(BookStub.Object.Isbn);

            // Assert
            book.ShouldBeEquivalentTo(BookStub.Object);
        }