Ejemplo n.º 1
0
        public void TestEnumDataElementsGeneration()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.DataContractDsl.Tests.xml");

            DataContractEnum rootElement = CreateDefaultDataContractEnum();

            rootElement.EnumNamedValues.AddRange(LoadEnumDataElements());
            string content = RunTemplate(rootElement);

            Type generatedType = CompileAndGetType(content);

            TypeAsserter.AssertExistPublicField(EnumElement1Name, generatedType);

            XmlEnumAttribute attrib = TypeAsserter.AssertAttribute <XmlEnumAttribute>(generatedType.GetField(EnumElement1Name));

            Assert.AreEqual <string>(EnumElement1Value, attrib.Name);

            TypeAsserter.AssertExistPublicField(EnumElement2Name, generatedType);
            attrib = TypeAsserter.AssertAttribute <XmlEnumAttribute>(generatedType.GetField(EnumElement2Name));
            Assert.AreEqual <string>(EnumElement2Value, attrib.Name);
        }