public void GivenArchive_WhenArchiveBookIsNull_ShouldReturnException() { // Arrange var books = new List <Book> { new Book { Id = 1, Name = "The Lord of the Rings", IsArchive = false }, new Book { Id = 2, Name = "Le Petit Prince", IsArchive = false }, new Book { Id = 3, Name = "Harry Potter and the Philosopher's Stone", IsArchive = false }, }; var bookMemoryStorage = new BookMemoryStorage(books); //Act TestDelegate testAction = () => bookMemoryStorage.Archive(null); //Assert var ex = Assert.Throws <InvalidOperationException>(testAction); Assert.That(ex.Message, Is.EqualTo("Can not archive null object!")); }
public void GivenGetAll_WhenBooksExist_ShouldReturnBookList() { // Arrange var books = new List <Book> { new Book { Id = 1, Name = "The Lord of the Rings", IsArchive = false }, new Book { Id = 2, Name = "Le Petit Prince", IsArchive = false }, new Book { Id = 3, Name = "Harry Potter and the Philosopher's Stone", IsArchive = false }, }; var store = new BookMemoryStorage(books); // Act var result = store.GetAll(); // Assert result.Should().BeEquivalentTo(new List <Book> { new Book { Id = 1, Name = "The Lord of the Rings", IsArchive = false }, new Book { Id = 2, Name = "Le Petit Prince", IsArchive = false }, new Book { Id = 3, Name = "Harry Potter and the Philosopher's Stone", IsArchive = false }, }); }
public void GivenArchive_WhenArchiveNonExistBook_ShouldReturnException() { // Arrange var book = new Book { Id = 4, Name = "Herbert Schildt C#", IsArchive = false }; var books = new List <Book> { new Book { Id = 1, Name = "The Lord of the Rings", IsArchive = false }, new Book { Id = 2, Name = "Le Petit Prince", IsArchive = false }, new Book { Id = 3, Name = "Harry Potter and the Philosopher's Stone", IsArchive = false }, }; var bookMemoryStorage = new BookMemoryStorage(books); //Act TestDelegate testAction = () => bookMemoryStorage.Archive(book); //Assert var ex = Assert.Throws <InvalidOperationException>(testAction); Assert.That(ex.Message, Is.EqualTo("There is not this item in the Item Storage!")); }
public void GivenDelete_WhenDeleteExistBook_ShouldReturnBookListWithoutDeletedBook() { // Arrange var book = new Book { Id = 3, Name = "Harry Potter and the Philosopher's Stone", IsArchive = false }; var books = new List <Book> { new Book { Id = 1, Name = "The Lord of the Rings", IsArchive = false }, new Book { Id = 2, Name = "Le Petit Prince", IsArchive = false }, new Book { Id = 3, Name = "Harry Potter and the Philosopher's Stone", IsArchive = false }, }; var bookMemoryStorage = new BookMemoryStorage(books); // Act bookMemoryStorage.Delete(book); var result = bookMemoryStorage.GetAll(); // Assert result.Should().BeEquivalentTo(new List <Book> { new Book { Id = 1, Name = "The Lord of the Rings", IsArchive = false }, new Book { Id = 2, Name = "Le Petit Prince", IsArchive = false } }); }
public void GivenGetAll_WhenBooksNotProvide_ShouldReturnEmptyList() { // Arrange var store = new BookMemoryStorage(null); // Act var result = store.GetAll(); // Assert result.Should().BeEmpty(); }