public void Humans_can_reproduce_when_there_is_a_name_a_mother_and_a_father() { Adam adam = Adam.GetInstance(); Eve eve = Eve.GetInstance(adam); Male seth = new Male("Seth", eve, adam); Female azura = new Female("Azura", eve, adam); Male enos = new Male("Enos", azura, seth); Assert.AreEqual("Eve", eve.Name); Assert.AreEqual("Adam", adam.Name); Assert.AreEqual("Seth", seth.Name); Assert.AreEqual("Azura", azura.Name); Assert.AreEqual("Enos", ((Human)enos).Name); Assert.AreEqual(seth, ((Human)enos).Father); Assert.AreEqual(azura, ((Human)enos).Mother); }
public void Human_can_reproduce_when_they_have_a_mother_and_father_and_have_a_name() { var adam = Adam.GetInstance(); var eve = Eve.GetInstance(adam); var seth = new Male("Seth", eve, adam); var azura = new Female("Azura", eve, adam); var enos = new Male("Enos", azura, seth); Assert.AreEqual("Eve", eve.Name); Assert.AreEqual("Adam", adam.Name); Assert.AreEqual("Seth", seth.Name); Assert.AreEqual("Azura", azura.Name); Assert.AreEqual("Enos", ((Human)enos).Name); Assert.AreEqual(seth, ((Human)enos).Father); Assert.AreEqual(azura, ((Human)enos).Mother); }
public void Eve_is_unique_and_created_from_a_rib_of_adam() { Adam adam = Adam.GetInstance(); Eve eve = Eve.GetInstance(adam); Eve anotherEve = Eve.GetInstance(adam); Assert.IsTrue(eve is Eve); Assert.AreEqual(eve, anotherEve); // GetInstance() is the only static method on Eve Assert.AreEqual(1, typeof(Eve).GetMethods().Where(x => x.IsStatic).Count()); // Eve has no public or internal constructor Assert.IsFalse(typeof(Eve).GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) .Any(x => x.IsPublic || x.IsAssembly)); // Eve cannot be overridden Assert.IsTrue(typeof(Eve).IsSealed); }
public void Father_and_mother_are_essential_for_reproduction() { // There is just 1 way to reproduce Assert.AreEqual(1, typeof(Male).GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) .Where(x => x.IsPublic || x.IsAssembly).Count()); Assert.AreEqual(1, typeof(Female).GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance). Where(x => x.IsPublic || x.IsAssembly).Count()); var adam = Adam.GetInstance(); var eve = Eve.GetInstance(adam); Assert.Throws <ArgumentNullException>(() => new Male("Seth", null, null)); Assert.Throws <ArgumentNullException>(() => new Male("Abel", eve, null)); Assert.Throws <ArgumentNullException>(() => new Male("Seth", null, adam)); Assert.Throws <ArgumentNullException>(() => new Female("Azura", null, null)); Assert.Throws <ArgumentNullException>(() => new Female("Awan", eve, null)); Assert.Throws <ArgumentNullException>(() => new Female("Dina", null, adam)); Assert.Throws <ArgumentNullException>(() => new Female("Eve", null, null)); Assert.Throws <ArgumentNullException>(() => new Male("Adam", null, null)); }
public void Eve_is_a_female() { Assert.IsTrue(Eve.GetInstance(Adam.GetInstance()) is Female); }
public void Eve_is_a_human() { Assert.IsTrue(Eve.GetInstance(Adam.GetInstance()) is Human); }
public void Eve_can_only_be_create_of_a_rib_of_adam() { Assert.Throws <ArgumentNullException>(() => Eve.GetInstance(null)); }
public void Eve_is_a_human() { Console.WriteLine(Adam.GetInstance() is Human); Assert.IsTrue(Eve.GetInstance(Adam.GetInstance()) is Human); }