public void DoValidateCollectionDataElementFailsForDuplicateNamedElements() { DataContract dataContract = CreateDataContract(); PrimitiveDataType part = Store.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType; part.Name = "foopart"; dataContract.DataMembers.Add(part); PrimitiveDataType part2 = Store.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType; part2.Name = part.Name; dataContract.DataMembers.Add(part2); TestableDataElementCollectionValidator target = new TestableDataElementCollectionValidator(); ValidationResults results = new ValidationResults(); target.TestDoValidateCollectionItem(part, dataContract, String.Empty, results); Assert.IsFalse(results.IsValid); Assert.AreEqual <int>(1, NumberOfErrors(results)); }
public void DoValidateCollectionDataElementFailsForEmptyNamedElements() { DataContract dataContract = CreateDataContract(); PrimitiveDataType part = Store.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType; part.Name = string.Empty; dataContract.DataMembers.Add(part); TestableDataElementCollectionValidator target = new TestableDataElementCollectionValidator(); ValidationResults results = new ValidationResults(); target.TestDoValidateCollectionItem(part, dataContract, String.Empty, results); Assert.IsFalse(results.IsValid); }
public void DoValidateCollectionDataElementFailsForDuplicateNamedElements() { DataContract dataContract = CreateDataContract(); PrimitiveDataType part = Store.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType; part.Name = "foopart"; dataContract.DataMembers.Add(part); PrimitiveDataType part2 = Store.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType; part2.Name = part.Name; dataContract.DataMembers.Add(part2); TestableDataElementCollectionValidator target = new TestableDataElementCollectionValidator(); ValidationResults results = new ValidationResults(); target.TestDoValidateCollectionItem(part, dataContract, String.Empty, results); Assert.IsFalse(results.IsValid); Assert.AreEqual<int>(1, NumberOfErrors(results)); }