public void TestValidation() { DomNodeType type = new DomNodeType("child"); ChildInfo test = new ChildInfo("test", type); CollectionAssert.IsEmpty(test.Rules); var rule = new SimpleChildRule(); test.AddRule(rule); Utilities.TestSequenceEqual(test.Rules, rule); Assert.True(test.Validate(null, null)); Assert.True(rule.Validated); }
public TestDataValidator() { m_childType = new DomNodeType("child"); m_parentType = new DomNodeType("parent"); m_parentType.Define(new ExtensionInfo <ValidationContext>()); m_parentType.Define(new ExtensionInfo <DataValidator>()); m_childCountRule = new ChildCountRule(2, 3); m_childInfo = new ChildInfo("child", m_childType, true); m_parentType.Define(m_childInfo); m_childInfo.AddRule(m_childCountRule); m_parent = new DomNode(m_parentType); m_parent.InitializeExtensions(); m_validationContext = m_parent.As <ValidationContext>(); m_child1 = new DomNode(m_childType); m_child2 = new DomNode(m_childType); m_child3 = new DomNode(m_childType); m_child4 = new DomNode(m_childType); }