public void VisitTest() { HomeStead homestead = new Nkandla(); homestead.Name = "Nkandla"; var stdOut = Console.Out; var output = new StringWriter(); Console.SetOut(output); _politician.visit(homestead); Console.SetOut(stdOut); Assert.AreEqual("A Jerk is now visiting the Nkandla home stead\r\n", output.ToString()); }
public string accept(Visitor person) { string returnStr; if (person is Politician) { Politician pol = (Politician)person; if (pol.getParty() == "ANC") { return(pol.visit(this)); } else { throw new VisitorNotAllowedException("Visit method could not be called, because this visitor may not enter " + name); } } else { throw new VisitorNotAllowedException("Visit method could not be called, because this person is not a visitor"); } }