コード例 #1
0
        public void UpdateTest_PassInvalidBook_ShouldNotRemoveFromCollection()
        {
            // Arrange
            JsonBookRepository jsonBookRepository = new JsonBookRepository();
            Book book = new Book();

            book.Title       = "Hello";
            book.Author      = "Sasha";
            book.DateOfissue = 1984;
            jsonBookRepository.Add(book);
            Book book2 = new Book();

            book2.Title       = "World";
            book2.Author      = "Vasya";
            book2.DateOfissue = 1991;
            book2.Id          = 0;

            // Act
            jsonBookRepository.Update(book2);

            //Assert
            Assert.AreEqual("Hello", book.Title);
            Assert.AreEqual("Sasha", book.Author);
            Assert.AreEqual(1984, book.DateOfissue);
        }
コード例 #2
0
        public void UpdateTest_PassValidBook_ShouldRemoveFromCollection()
        {
            // Arrange
            JsonBookRepository jsonBookRepository = new JsonBookRepository();
            Book book = new Book();

            book.Name        = "Hello";
            book.Author      = "Sasha";
            book.YearOfIssue = 1984;
            jsonBookRepository.Add(book);
            int  id    = book.Id;
            Book book2 = new Book();

            book2.Name        = "World";
            book2.Author      = "Vasya";
            book2.YearOfIssue = 1991;
            book2.Id          = id;

            // Act
            jsonBookRepository.Update(book2);

            //Assert
            Assert.AreEqual("World", book.Name);
            Assert.AreEqual("Vasya", book.Author);
            Assert.AreEqual(1991, book.YearOfIssue);
        }