コード例 #1
0
        public void Library_AddAuthor_Correct()
        {
            // Arrage
            List <Author> authors = new List <Author>()
            {
                new Author()
                {
                    Id = 1, Name = "Name0", Surname = "Surname0"
                },
                new Author()
                {
                    Id = 2, Name = "Name1", Surname = "Surname1"
                },
                new Author()
                {
                    Id = 3, Name = "Name2", Surname = "Surname2"
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetAuthors()).Returns(authors);

            ILibrary library   = new LibraryCollection(data.Object);
            Author   newAuthor = new Author()
            {
                Id = 20, Name = "Name10", Surname = "Surname10"
            };

            // Act
            authors.Add(newAuthor);
            library.AddAuthor(newAuthor);

            // Assert
            Assert.Equal(authors, library.GetAuthors());
        }