Example #1
0
        public void Delete_WhenInvokedWithUnexistingIsbn_ThenShouldReturnFalse()
        {
            // Arrange
            var catalog = new Catalog();

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

            // Assert
            result.Should().BeFalse();
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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();
        }
Example #5
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();
        }