public void Welcome_WhenWelcomingAMaleNoble_ShouldSayHelloSirLastName() { // Arrange GoodHost host = new GoodHost(); Guest maleCommoner = new Guest { Name = "Arthur Lancelot", Gender = Gender.Male, Status = Status.Noble }; // Act var greeting = host.Welcome(maleCommoner); // Assert Assert.AreEqual(expected: "Hello Sir Lancelot", actual: greeting); }
public void Welcome_WhenWelcomingAMaleCommoner_ShouldSayHelloMrLastName() { // Arrange GoodHost host = new GoodHost(); Guest maleCommoner = new Guest { Name = "John Doe", Gender = Gender.Male, Status = Status.Commoner}; // Act var greeting = host.Welcome(maleCommoner); // Assert Assert.AreEqual(expected: "Hello Mr. Doe", actual: greeting); }
public void Welcome_WhenWelcomingAFemaleCommoner_ShouldSayHelloMsLastName() { // Arrange GoodHost host = new GoodHost(); Guest femaleCommoner = new Guest {Name = "Silvia Williams", Gender = Gender.Female, Status = Status.Commoner}; // Act var greeting = host.Welcome(femaleCommoner); // Assert Assert.AreEqual(expected: "Hello Ms. Williams", actual: greeting); }
public void Welcome_WhenWelcomingAFemaleNoble_ShouldSayHelloLadyLastName() { // Arrange GoodHost host = new GoodHost(); Guest femaleNoble = new Guest {Name = "Laura Fitzpatrick", Gender = Gender.Female, Status = Status.Noble}; // Act var greeting = host.Welcome(femaleNoble); // Assert Assert.AreEqual(expected: "Hello Lady Fitzpatrick", actual: greeting); }
/// <summary> /// Welcome a guest /// </summary> /// <param name="guest">Guest</param> /// <returns>An appropriate greeting message tailored for each guest</returns> public string Welcome(Guest guest) { StringBuilder sb = new StringBuilder(); sb.Append("Hello "); if (guest.Gender == Gender.Female) sb.Append(guest.Status == Status.Commoner ? "Ms. " : "Lady "); else sb.Append(guest.Status == Status.Commoner ? "Mr. " : "Sir "); sb.Append(guest.LastName); return sb.ToString(); }