public void ShouldGenerateKnownTypeAttributeWithXsdExtendedTypes()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml");

            ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace);

            rootElement.ServiceContractModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider();
            rootElement.ServiceContractModel.SerializerType           = Microsoft.Practices.ServiceFactory.ServiceContracts.SerializerType.DataContractSerializer;
            Operation op1 = new Operation(Store);

            op1.ObjectExtender  = new WCFOperationContract();
            op1.Name            = "op1";
            op1.Action          = "op1";
            op1.ServiceContract = rootElement;
            XsdMessage request = new XsdMessage(Store);

            request.Name    = "Request1";
            request.Element = @"xsd://SampleData/BaseTypes.xsd?LandmarkPoint";
            request.ServiceContractModel = rootElement.ServiceContractModel;
            WCFXsdMessageContract wcfXsdMc = new WCFXsdMessageContract();

            wcfXsdMc.ModelElement  = request;
            request.ObjectExtender = wcfXsdMc;

            op1.Request = request;
            string content = RunTemplate(rootElement);

            EnsureType(ref content, "Request1");
            EnsureType(ref content, "LandmarkBase");
            Type       generatedType            = CompileAndGetType(content);
            MethodInfo method                   = TypeAsserter.AssertMethod(op1.Name, generatedType);
            ServiceKnownTypeAttribute attribute = TypeAsserter.AssertAttribute <ServiceKnownTypeAttribute>(method);

            Assert.AreEqual <string>("LandmarkBase", attribute.Type.Name);
        }
        public void TestXsdMessageWrappedRequestGeneration()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml");

            ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace);

            rootElement.ServiceContractModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider();

            Operation op1 = new Operation(Store);

            op1.ObjectExtender  = new WCFOperationContract();
            op1.Name            = "op1";
            op1.Action          = "op1";
            op1.ServiceContract = rootElement;
            XsdMessage request = new XsdMessage(Store);

            request.Name                 = "Request1";
            request.Element              = @"xsd://SampleData/SimpleSchema1.xsd?element1";
            request.IsWrapped            = true;
            request.ServiceContractModel = rootElement.ServiceContractModel;
            WCFXsdMessageContract wcfXsdMc = new WCFXsdMessageContract();

            wcfXsdMc.ModelElement  = request;
            request.ObjectExtender = wcfXsdMc;

            op1.Request = request;
            string content = RunTemplate(rootElement);

            EnsureType(ref content, "Request1");
            Type       generatedType = CompileAndGetType(content);
            MethodInfo method        = TypeAsserter.AssertMethod(op1.Name, generatedType);

            Assert.AreEqual <int>(1, method.GetParameters().Length);
            Assert.AreEqual <string>("Request1", ((ParameterInfo)method.GetParameters().GetValue(0)).ParameterType.Name);
            Assert.AreEqual <string>("Void", method.ReturnType.Name);
        }
		public void ShouldGenerateKnownTypeAttributeWithXsdExtendedTypesNotDuplicated()
		{
			ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml");

			ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace);
			rootElement.ServiceContractModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider();
			rootElement.ServiceContractModel.SerializerType = Microsoft.Practices.ServiceFactory.ServiceContracts.SerializerType.DataContractSerializer;
			Operation op1 = new Operation(Store);
			op1.ObjectExtender = new WCFOperationContract();
			op1.Name = "op1";
			op1.Action = "op1";
			op1.ServiceContract = rootElement;

			XsdMessage request = new XsdMessage(Store);
			request.Name = "Request1";
			request.Element = @"xsd://SampleData/BaseTypes.xsd?LandmarkPoint";
			request.ServiceContractModel = rootElement.ServiceContractModel;
			WCFXsdMessageContract wcfXsdMc = new WCFXsdMessageContract();
			wcfXsdMc.ModelElement = request;
			request.ObjectExtender = wcfXsdMc;

			XsdMessage response = new XsdMessage(Store);
			response.Name = "Response1";
			response.Element = @"xsd://SampleData/BaseTypes.xsd?LandmarkPoint";
			response.ServiceContractModel = rootElement.ServiceContractModel;
			WCFXsdMessageContract wcfXsdMc2 = new WCFXsdMessageContract();
			wcfXsdMc2.ModelElement = request;
			response.ObjectExtender = wcfXsdMc2;

			op1.Request = request;
			op1.Response = response;
			string content = RunTemplate(rootElement);

			EnsureType(ref content, "Request1");
			EnsureType(ref content, "Response1");
			EnsureType(ref content, "LandmarkBase");
			Type generatedType = CompileAndGetType(content);
			MethodInfo method = TypeAsserter.AssertMethod(op1.Name, generatedType);
			ServiceKnownTypeAttribute attribute = TypeAsserter.AssertAttribute<ServiceKnownTypeAttribute>(method);
			Assert.AreEqual<string>("LandmarkBase", attribute.Type.Name);
		}
		public void TestXsdMessageWrappedRequestGeneration()
		{
			ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml");

			ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace);
			rootElement.ServiceContractModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider();

			Operation op1 = new Operation(Store);
			op1.ObjectExtender = new WCFOperationContract();
			op1.Name = "op1";
			op1.Action = "op1";
			op1.ServiceContract = rootElement;
			XsdMessage request = new XsdMessage(Store);
			request.Name = "Request1";
			request.Element = @"xsd://SampleData/SimpleSchema1.xsd?element1";
			request.IsWrapped = true;
			request.ServiceContractModel = rootElement.ServiceContractModel;
			WCFXsdMessageContract wcfXsdMc = new WCFXsdMessageContract();
			wcfXsdMc.ModelElement = request;
			request.ObjectExtender = wcfXsdMc;

			op1.Request = request;
			string content = RunTemplate(rootElement);

			EnsureType(ref content, "Request1");
			Type generatedType = CompileAndGetType(content);
			MethodInfo method = TypeAsserter.AssertMethod(op1.Name, generatedType);
			Assert.AreEqual<int>(1, method.GetParameters().Length);
			Assert.AreEqual<string>("Request1", ((ParameterInfo)method.GetParameters().GetValue(0)).ParameterType.Name);
			Assert.AreEqual<string>("Void", method.ReturnType.Name);
		}