public void DoValidateCollectionDataElementFailsForEmptyNamedElements()
		{
			DataContractEnum dataContract = CreateDataContract();

			EnumNamedValue part = Store.ElementFactory.CreateElement(EnumNamedValue.DomainClassId) as EnumNamedValue;
			part.Name = string.Empty;
			dataContract.EnumNamedValues.Add(part);

			TestableDataContractEnumDataElementCollectionValidator target = new TestableDataContractEnumDataElementCollectionValidator();

			ValidationResults results = new ValidationResults();
			target.TestDoValidateCollectionItem(part, dataContract, String.Empty, results);

			Assert.IsFalse(results.IsValid);
		}
Ejemplo n.º 2
0
        public void DoValidateCollectionDataElementFailsForEmptyNamedElements()
        {
            DataContractEnum dataContract = CreateDataContract();

            EnumNamedValue part = Store.ElementFactory.CreateElement(EnumNamedValue.DomainClassId) as EnumNamedValue;

            part.Name = string.Empty;
            dataContract.EnumNamedValues.Add(part);

            TestableDataContractEnumDataElementCollectionValidator target = new TestableDataContractEnumDataElementCollectionValidator();

            ValidationResults results = new ValidationResults();

            target.TestDoValidateCollectionItem(part, dataContract, String.Empty, results);

            Assert.IsFalse(results.IsValid);
        }
		public void DoValidateCollectionDataElementFailsForDuplicateNamedElements()
		{
			DataContractEnum dataContract = CreateDataContract();

			EnumNamedValue part = Store.ElementFactory.CreateElement(EnumNamedValue.DomainClassId) as EnumNamedValue;
			part.Name = "foo";
			dataContract.EnumNamedValues.Add(part);

			EnumNamedValue part2 = Store.ElementFactory.CreateElement(EnumNamedValue.DomainClassId) as EnumNamedValue;
			part2.Name = part.Name;

			dataContract.EnumNamedValues.Add(part2);

			TestableDataContractEnumDataElementCollectionValidator target = new TestableDataContractEnumDataElementCollectionValidator();

			ValidationResults results = new ValidationResults();
			target.TestDoValidateCollectionItem(part, dataContract, String.Empty, results);

			Assert.IsFalse(results.IsValid);
			Assert.AreEqual<int>(1, NumberOfErrors(results));
		}
Ejemplo n.º 4
0
        public void DoValidateCollectionDataElementFailsForDuplicateNamedElements()
        {
            DataContractEnum dataContract = CreateDataContract();

            EnumNamedValue part = Store.ElementFactory.CreateElement(EnumNamedValue.DomainClassId) as EnumNamedValue;

            part.Name = "foo";
            dataContract.EnumNamedValues.Add(part);

            EnumNamedValue part2 = Store.ElementFactory.CreateElement(EnumNamedValue.DomainClassId) as EnumNamedValue;

            part2.Name = part.Name;

            dataContract.EnumNamedValues.Add(part2);

            TestableDataContractEnumDataElementCollectionValidator target = new TestableDataContractEnumDataElementCollectionValidator();

            ValidationResults results = new ValidationResults();

            target.TestDoValidateCollectionItem(part, dataContract, String.Empty, results);

            Assert.IsFalse(results.IsValid);
            Assert.AreEqual <int>(1, NumberOfErrors(results));
        }