public void AddTest() { LogicContainer_Accessor target = new LogicContainer_Accessor(); List<CounterComponent> counters = new List<CounterComponent>() { new NoneCounter(), new DraweableCounter(), new BothCounter(), new UpdateableCounter(), }; foreach (var item in counters) target.Add(item); Assert.AreEqual(2, target.m_Drawable.Count); Assert.AreEqual(4, target.m_Items.Count); Assert.AreEqual(2, target.m_Updateable.Count); }
public void DrawTest() { LogicContainer_Accessor target = new LogicContainer_Accessor(); DraweableCounter drawable = new DraweableCounter(); List<CounterComponent> counters = new List<CounterComponent>() { new NoneCounter(), drawable, new BothCounter(), new UpdateableCounter(), }; foreach (var item in counters) target.Add(item); target.Draw(); Assert.AreEqual(1, drawable.DrawCount); }
public void UpdateTest() { LogicContainer_Accessor target = new LogicContainer_Accessor(); UpdateableCounter updateable = new UpdateableCounter(); BothCounter both = new BothCounter(); List<CounterComponent> counters = new List<CounterComponent>() { new NoneCounter(), new DraweableCounter(), both, updateable }; foreach (var item in counters) target.Add(item); target.Update(0); Assert.AreEqual(1, updateable.UpdateCount); Assert.AreEqual(1, both.UpdateCount); target.Remove(updateable); target.Update(0); Assert.AreEqual(1, updateable.UpdateCount); Assert.AreEqual(2, both.UpdateCount); }
public void TestUnLink() { LogicContainer_Accessor target = new LogicContainer_Accessor(); List<CounterComponent> counters = new List<CounterComponent>() { new NoneCounter(), new DraweableCounter(), new BothCounter(), new UpdateableCounter(), }; foreach (var item in counters) target.Add(item); target.Remove(counters[0]); Assert.AreEqual(3, counters[0].CountRemoved); counters.RemoveAt(0); Assert.IsTrue(counters.TrueForAll(item => item.CountRemoved == 1)); }
public void TestLink() { LogicContainer_Accessor target = new LogicContainer_Accessor(); List<CounterComponent> counters = new List<CounterComponent>() { new NoneCounter(), new DraweableCounter(), new BothCounter(), new UpdateableCounter(), }; foreach (var item in counters) target.Add(item); Assert.IsTrue(counters.TrueForAll(item => item.CountAdded == 3)); }
public void GetFirstImplementingTest() { LogicContainer_Accessor target = new LogicContainer_Accessor(); // TODO: Initialize to an appropriate value List<IDependent> dependents = new List<IDependent>() { new One(), new Three(), new Two(), }; dependents.ForEach(target.Add); TestInterface item = target.GetFirstImplementing<TestInterface>(); Assert.AreSame(dependents[1], item); One one = target.GetFirstImplementing<One>(); Assert.AreSame(dependents[0], one); }
public void GetAllImplementingTest() { LogicContainer_Accessor target = new LogicContainer_Accessor(); // TODO: Initialize to an appropriate value List<IDependent> dependents = new List<IDependent>() { new One(), new Three(), new Two(), }; dependents.ForEach(target.Add); IEnumerable<TestInterface> items = target.GetAllImplementing<TestInterface>(); Assert.AreEqual(2, items.Count()); IEnumerable<One> ones = target.GetAllImplementing<One>(); Assert.AreEqual(2, ones.Count()); }