public void RunStructTest() { Console.WriteLine("In test"); StructEggbox eggs = new StructEggbox(0); AddEggs(eggs); Assert.AreEqual(0, eggs.Count); }
public void RunStructTestFixed() { Console.WriteLine("In test"); Object eggs = new StructEggbox(0); AddEggs((IRunningTotal)eggs); Assert.AreEqual(12, ((IRunningTotal)eggs).Count); //((StructEggbox)eggs)._eggCount += 12; // Not allowed by compiler StructEggbox copied = (StructEggbox)eggs; copied._eggCount += 12; Assert.AreEqual(12, ((IRunningTotal)eggs).Count); }
public void WhenAllocation() { Console.WriteLine("In test"); { StructEggbox eggs = new StructEggbox(12); AddEggs(eggs); Assert.AreEqual(12, eggs.Count); } { ClassEggbox eggs = new ClassEggbox(12); AddEggs(eggs); Assert.AreEqual(24, eggs.Count); } }
public void WhenIamCalled(bool flag) { Console.WriteLine("I am in the block"); if (flag) { Console.WriteLine("Flag is (" + flag + ")"); StructEggbox[] eggs = new StructEggbox[20000]; AddEggs(eggs[0]); Console.WriteLine("Count (" + eggs[0].Count + ")"); } else if (!flag) { StructEggbox eggs2 = new StructEggbox(24); AddEggs(eggs2); } }
public void WhenIamCalled3(bool flag) { Console.WriteLine("I am in the block"); if (flag) { Console.WriteLine("Flag is (" + flag + ")"); ClassEggbox eggs = new ClassEggbox(12); AddEggs((IRunningTotal)eggs); Console.WriteLine("Count (" + ((IRunningTotal)eggs).Count + ")"); } else if (!flag) { StructEggbox eggs2 = new StructEggbox(24); AddEggs(eggs2); } }