public void GetStatesTest() { DTRuleSet_Accessor target = new DTRuleSet_Accessor(ElementData); foreach (var dataPair in ElementData) { CollectionAssert.AreEqual(dataPair.Value, target.GetStates(dataPair.Key).ToList()); } }
private void SortRulesTestCase2() { List<DTElement> elements = new List<DTElement>(); for (int i = 0; i < 3; i++) elements.Add(new DTElement { Name = string.Format("Condition {0}", i), Kind = DTElementKind.Condition }); for (int i = 0; i < 2; i++) elements.Add(new DTElement { Name = string.Format("Action {0}", i), Kind = DTElementKind.Action }); var f = DTState.No; var t = DTState.Yes; var e = DTState.Empty; var a = DTState.ActionYes; var notOrdered = new List<List<DTState>> { new DTState[] { t, f, f, t, f, f, t, t, t, f }.ToList(), new DTState[] { f, t, f, t, t, f, t, f, t, f }.ToList(), new DTState[] { f, t, f, t, f, t, f, t, f, f }.ToList(), new DTState[] { e, e, e, a, a, e, e, e, e, e }.ToList(), new DTState[] { a, a, e, a, e, a, a, e, a, e }.ToList() }; for (int i = 0; i < elements.Count; i++) elements[i].SetStates(notOrdered[i]); var ordered = new List<List<DTState>> { new DTState[] { t, t, t, t, t, f, f, f, f, f }.ToList(), new DTState[] { t, t, t, f, f, t, t, f, f, f }.ToList(), new DTState[] { t, f, f, t, f, t, f, t, f, f }.ToList(), new DTState[] { a, e, e, e, e, e, a, e, e, e }.ToList(), new DTState[] { a, a, a, e, a, a, e, a, e, e }.ToList() }; DTRuleSet_Accessor actual = new DTRuleSet_Accessor(elements); for (int i = 0; i < elements.Count; i++) { CollectionAssert.AreNotEqual(ordered[i], actual.GetStates(elements[i]).ToList()); } actual.SortRules(); for (int i = 0; i < elements.Count; i++) { CollectionAssert.AreEqual(ordered[i], actual.GetStates(elements[i]).ToList()); } DTRuleSet actual1 = DTRuleSet.SortRules(elements); for (int i = 0; i < elements.Count; i++) { CollectionAssert.AreEqual(ordered[i], actual1.GetStates(elements[i]).ToList()); } }