public void TestPrimitiveHeaderGenerationWithDictionaryCollectionType()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.DataContractDsl.Tests.xml");

            PrimitiveDataTypeCollection collectionElement =
                CreateDefaultPrimitiveDataTypeCollection(typeof(Dictionary <,>), PrimitiveDataElementType1);
            TemplateResult result = RunTemplateWithErrors(collectionElement);

            // should have a warning
            Assert.AreEqual <int>(1, result.Errors.Length);

            string content = result.ContentResults;

            Type generatedType = CompileAndGetType(content);

            Assert.IsTrue(generatedType.IsClass);
            Assert.AreEqual <Type>(typeof(Collection <int>), generatedType.BaseType);
            XmlRootAttribute xmlRootAttr = TypeAsserter.AssertAttribute <XmlRootAttribute>(generatedType);

            Assert.AreEqual <string>(ElementNamespace, xmlRootAttr.Namespace);
            Assert.IsFalse(xmlRootAttr.IsNullable);
            XmlTypeAttribute xmlTypeAttr = TypeAsserter.AssertAttribute <XmlTypeAttribute>(generatedType);

            Assert.AreEqual <string>(ElementNamespace, xmlTypeAttr.Namespace);
        }
        private PrimitiveDataTypeCollection CreateDefaultPrimitiveDataTypeCollection(Type collectionType,
                                                                                     string itemType)
        {
            PrimitiveDataTypeCollection rootElement = new PrimitiveDataTypeCollection(Store);

            rootElement.DataContractModel = new DataContractModel(Store);
            rootElement.DataContractModel.ProjectMappingTable = "ASMX";
            rootElement.Name           = ElementName;
            rootElement.Namespace      = ElementNamespace;
            rootElement.ObjectExtender = AttachDataContractCollectionExtender(rootElement, collectionType);
            rootElement.ItemType       = itemType;
            return(rootElement);
        }
        public void TestPrimitiveHeaderGeneration()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.DataContractDsl.Tests.xml");

            PrimitiveDataTypeCollection collectionElement = CreateDefaultPrimitiveDataTypeCollection(typeof(Collection <>), PrimitiveDataElementType1);
            string content = RunTemplate(collectionElement);

            Type generatedType = CompileAndGetType(content);

            Assert.IsTrue(generatedType.IsClass);
            Assert.AreEqual <Type>(typeof(Collection <int>), generatedType.BaseType);
            CollectionDataContractAttribute collectionAttr = TypeAsserter.AssertAttribute <CollectionDataContractAttribute>(generatedType);

            Assert.AreEqual <string>(ElementNamespace, collectionAttr.Namespace);
        }
        public void TestPrimitiveHeaderGenerationWithArrayCollectionType()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.DataContractDsl.Tests.xml");

            PrimitiveDataTypeCollection collectionElement =
                CreateDefaultPrimitiveDataTypeCollection(typeof(Array), PrimitiveDataElementType1);
            TemplateResult result = RunTemplateWithErrors(collectionElement);

            // should have a warning
            Assert.AreEqual <int>(1, result.Errors.Length);

            string content = result.ContentResults;

            Type generatedType = CompileAndGetType(content);

            Assert.IsTrue(generatedType.IsClass);
            Assert.AreEqual <Type>(typeof(Collection <int>), generatedType.BaseType);
        }