public void TestLookupCount() { IBlackboard blackboard = new Blackboard(); TestUnit1 u1 = new TestUnit1("one"); TestUnit1 u2 = new TestUnit1("two"); TestUnit1 u3 = new TestUnit1("three"); TestUnit2 u4 = new TestUnit2(1); TestUnit2 u5 = new TestUnit2(2); string type1 = u1.GetType().FullName; string type2 = u4.GetType().FullName; blackboard.AddUnit(u1); blackboard.AddUnit(u2); blackboard.AddUnit(u3); blackboard.AddUnit(u4); blackboard.AddUnit(u5); ISet <IUnit> set1 = blackboard.LookupUnits(type1); ISet <IUnit> set2 = blackboard.LookupUnits(type2); Assert.Equal(3, set1.Count); Assert.Equal(2, set2.Count); }
public void TestLookupNotNull() { IBlackboard blackboard = new Blackboard(); TestUnit1 u1 = new TestUnit1("one"); TestUnit2 u2 = new TestUnit2(1); string type1 = u1.GetType().FullName; string type2 = u2.GetType().FullName; blackboard.AddUnit(u1); blackboard.AddUnit(u2); Assert.NotNull(blackboard.LookupUnits(type1)); Assert.NotNull(blackboard.LookupUnits(type2)); }
// Deleting and adding elements to a returned set shouldn't change the set in the dictionary public void TestManipulatingSet() { IBlackboard blackboard = new Blackboard(); TestUnit1 u1 = new TestUnit1("one"); TestUnit1 u2 = new TestUnit1("two"); string type1 = u1.GetType().FullName; blackboard.AddUnit(u1); ISet <IUnit> set1 = blackboard.LookupUnits(type1); Assert.Equal(1, set1.Count); set1.Add(u2); ISet <IUnit> set2 = blackboard.LookupUnits(type1); Assert.Equal(1, set2.Count); set2.Remove(u1); ISet <IUnit> set3 = blackboard.LookupUnits(type1); Assert.Equal(1, set3.Count); }