public void ChangeCouplesTest() { Man man = new Man("Pablo"); Man newMan = new Man("Paco"); Woman scarlett = new Woman("Scarlett"); Woman catherine = new Woman("Catherine"); man.AddWife(scarlett); newMan.AddWife(catherine); // Couples are established properly Assert.IsTrue(man.HasMarried(scarlett)); Assert.IsTrue(newMan.HasMarried(catherine)); Assert.AreEqual(scarlett.Husband, man); Assert.AreEqual(catherine.Husband, newMan); man.AddWife(catherine); newMan.AddWife(scarlett); // Couples are rearranged Assert.IsTrue(man.HasMarried(catherine)); Assert.IsTrue(newMan.HasMarried(scarlett)); Assert.AreEqual(scarlett.Husband, newMan); Assert.AreEqual(catherine.Husband, man); } // ChangeCouplesTest
public void RemoveWifeTest() { Man man = new Man("Pablo"); Woman scarlett = new Woman("Scarlett"); Woman catherine = new Woman("Catherine"); man.AddWife(scarlett); man.RemoveWife(scarlett); Assert.IsFalse(man.HasMarried(scarlett)); Assert.IsFalse(man.HasMarried(catherine)); man.AddWife(scarlett); man.AddWife(catherine); man.RemoveWife(scarlett); Assert.IsFalse(man.HasMarried(scarlett)); Assert.IsTrue(man.HasMarried(catherine)); } // RemoveWifeTest
public void HasMarriedTest() { Man man = new Man("Pablo"); Woman scarlett = new Woman("Scarlett"); Woman catherine = new Woman("Catherine"); // I married Scarlett, which means Scarlett marries me man.AddWife(scarlett); Assert.IsTrue(man.HasMarried(scarlett)); Assert.IsFalse(man.HasMarried(catherine)); } // HasMarried
public void AddWifeTest() { Man man = new Man("Pablo"); Woman scarlett = new Woman("Scarlett"); Woman catherine = new Woman("Catherine"); // I married Scarlett, which means Scarlett marries me man.AddWife(scarlett); Assert.IsTrue(man.HasMarried(scarlett)); Assert.AreEqual(scarlett.Husband, man); Assert.IsFalse(man.HasMarried(catherine)); Assert.IsTrue(catherine.Husband == null); // I married Catherine also, which means Catherine marries me man.AddWife(catherine); Assert.IsTrue(man.HasMarried(scarlett)); Assert.IsTrue(man.HasMarried(catherine)); Assert.AreEqual(scarlett.Husband, man); Assert.AreEqual(catherine.Husband, man); } // AddWifeTest