public void AddNewspaper_MultipleTimesWithValidNewspaperObjects_CreatesAReferenceToEachPaper() { // Arrange var paper1 = new Newspaper() { Name = "Paper 1 name" }; var paper2 = new Newspaper() { Name = "Paper 2 name" }; var ad = new Advertisement { Name = "Test ad 1 name", Text = "Test ad 1 text." }; // Act ad.AddNewspaper(paper1); ad.AddNewspaper(paper2); // Assert ad.Newspapers.ShouldBeEquivalentTo(new List <Newspaper> { paper2, paper1 }); }
public void AddNewspapers_WithNullNewspaperList_ReturnsTheOriginalNewspapersCollection() { // Arrange var paper1 = new Newspaper() { Name = "Paper 1 name" }; var paper2 = new Newspaper() { Name = "Paper 2 name" }; var paper3 = new Newspaper() { Name = "Paper 3 name" }; var ad = new Advertisement { Name = "Test ad 1 name", Text = "Test ad 1 text." }; var paperList = new List <Newspaper> { paper1, paper3, paper2 }; ad.AddNewspaper(paper1); ad.AddNewspaper(paper2); ad.AddNewspaper(paper3); // Act ad.AddNewspapers(null); // Assert ad.Newspapers.ShouldAllBeEquivalentTo(paperList); }
public void AddNewspaper_WithNull_DoesNotChangeTheNewspapersCollection() { // Arrange var advertisement = new Advertisement { Name = "Test Ad 1", Text = "Test ad 1 text." }; // Act advertisement.AddNewspaper(null); // Assert advertisement.Newspapers.ShouldAllBeEquivalentTo(new List <Newspaper>()); }
public void AddNewspaper_WithValidNewspaperObject_CreatesAReferenceToThatNewspaper() { // Arrange var paper = new Newspaper() { Name = "Test Paper 1" }; var advertisement = new Advertisement { Name = "Test Ad 1", Text = "Test ad 1 text." }; // Act advertisement.AddNewspaper(paper); //Assert advertisement.Newspapers.ShouldAllBeEquivalentTo(new List <Newspaper> { paper }, "A paper added to an advertisement adds a reference to that paper."); }