예제 #1
0
        public void ReturnSuccessForValidCollection()
        {
            Store store = new Store(new MockServiceProvider(), typeof(CoreDesignSurfaceDomainModel), typeof(DataContractDslDomainModel));

            using (Transaction t = store.TransactionManager.BeginTransaction())
            {
                DataContract dcElement = store.ElementFactory.CreateElement(DataContract.DomainClassId) as DataContract;

                PrimitiveDataType element1  = store.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType;
                WCFDataElement    extension = new WCFDataElement();
                extension.Order         = 0;
                element1.ObjectExtender = extension;

                dcElement.DataMembers.Add(element1);

                PrimitiveDataType element2 = store.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType;
                extension.Order         = 2;
                element2.ObjectExtender = extension;

                dcElement.DataMembers.Add(element2);

                UniqueOrderPropertyCollectionValidator validator = new UniqueOrderPropertyCollectionValidator(null);
                ValidationResults validationResults = validator.Validate(dcElement.DataMembers);

                Assert.IsFalse(validationResults.IsValid);

                t.Rollback();
            }
        }
		public void ReturnSuccessForValidCollection()
		{
            Store store = new Store(new MockServiceProvider(), typeof(CoreDesignSurfaceDomainModel), typeof(DataContractDslDomainModel));

            using (Transaction t = store.TransactionManager.BeginTransaction())
            {
                DataContract dcElement = store.ElementFactory.CreateElement(DataContract.DomainClassId) as DataContract;

                PrimitiveDataType element1 = store.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType;
                WCFDataElement extension = new WCFDataElement();
                extension.Order = 0;
                element1.ObjectExtender = extension;

                dcElement.DataMembers.Add(element1);

                PrimitiveDataType element2 = store.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType;
                extension.Order = 2;
                element2.ObjectExtender = extension;

                dcElement.DataMembers.Add(element2);

                UniqueOrderPropertyCollectionValidator validator = new UniqueOrderPropertyCollectionValidator(null);
                ValidationResults validationResults = validator.Validate(dcElement.DataMembers);

                Assert.IsFalse(validationResults.IsValid);

                t.Rollback();
            }
		}
예제 #3
0
        public void TestWCFDataElementPropertiesGeneration()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.DataContractDsl.Tests.xml");
            DataContract   rootElement = CreateDefaultDataContract();
            WCFDataElement dataElement = new WCFDataElement();

            dataElement.IsRequired = true;
            dataElement.Order      = 1;
            PrimitiveDataType element = LoadDefaultPrimitiveDataElement();

            element.ObjectExtender = dataElement;
            rootElement.DataMembers.Add(element);
            string content = RunTemplate(rootElement);

            Type generatedType             = CompileAndGetType(content);
            DataMemberAttribute dataMember = TypeAsserter.AssertAttribute <DataMemberAttribute>(generatedType.GetProperty(element.Name));

            Assert.IsTrue(dataMember.IsRequired);
            Assert.AreEqual <int>(1, dataMember.Order);
        }
		public void TestWCFDataElementPropertiesGeneration()
		{
			ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.DataContractDsl.Tests.xml");
			DataContract rootElement = CreateDefaultDataContract();
			WCFDataElement dataElement = new WCFDataElement();
			dataElement.IsRequired = true;
			dataElement.Order = 1;
			PrimitiveDataType element = LoadDefaultPrimitiveDataElement();
			element.ObjectExtender = dataElement;
			rootElement.DataMembers.Add(element);
			string content = RunTemplate(rootElement);

			Type generatedType = CompileAndGetType(content);
			DataMemberAttribute dataMember = TypeAsserter.AssertAttribute<DataMemberAttribute>(generatedType.GetProperty(element.Name));
			Assert.IsTrue(dataMember.IsRequired);
			Assert.AreEqual<int>(1, dataMember.Order);
		}