public void AddPaperTest_NormalPath() { Paper p = new Paper("not winning", "sean boyd", "teaches you how to lose", 1535); PaperList actual = new PaperList(); actual.addPaper(p); Paper expected = new Paper("not winning", "sean boyd", "teaches you how to lose", 1535); Assert.AreEqual(expected.getName(), actual.getPaper("not winning").getName()); }
public void AddPaperTest_HasPaper() { Paper p = new Paper("not winning", "sean boyd", "teaches you how to lose", 1535); Paper p1 = new Paper("test", "test mcgee", "how to test", 2012); PaperList actual = new PaperList(); actual.addPaper(p1); actual.addPaper(p); Paper expected = new Paper("not winning", "sean boyd", "teaches you how to lose", 1535); Assert.AreEqual(expected.getName(), actual.getPaper("not winning").getName()); }
public void addPaper(Paper paper) { if (String.IsNullOrEmpty(paper.getName())) { return; } if (this.list == null) { this.list = new List<Paper>() { paper }; } for (int i = 0; i < this.list.Count; i++) { if (this.list[i].getName().Equals(paper.getName())) { return; } } this.list.Add(paper); }
public PaperList(Paper paper) { this.list = new List<Paper> { paper }; }