public void TestAsyncOperationGeneration() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); Operation op1 = new Operation(Store); WCFOperationContract wfcOperationContract = new WCFOperationContract(); wfcOperationContract.AsyncPattern = true; op1.ObjectExtender = wfcOperationContract; op1.Name = "op1"; op1.Action = "op1"; op1.ServiceContract = rootElement; string content = RunTemplate(rootElement); Type generatedType = CompileAndGetType(content); MethodInfo beginMethod = TypeAsserter.AssertMethod("Begin" + op1.Name, generatedType); Assert.AreEqual <int>(2, beginMethod.GetParameters().Length); Assert.AreEqual <string>("IAsyncResult", beginMethod.ReturnType.Name); MethodInfo endMethod = TypeAsserter.AssertMethod("End" + op1.Name, generatedType); Assert.AreEqual <int>(1, endMethod.GetParameters().Length); Assert.AreEqual <string>("Void", endMethod.ReturnType.Name); }
public void TestReplyActionGeneration() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); Operation op1 = new Operation(Store); WCFOperationContract oc = new WCFOperationContract(); oc.ReplyAction = "foo"; op1.ObjectExtender = oc; op1.Name = "op1"; op1.ServiceContract = rootElement; string content = RunTemplate(rootElement); Type generatedType = CompileAndGetType(content); MethodInfo method = TypeAsserter.AssertMethod(op1.Name, generatedType); OperationContractAttribute operation = TypeAsserter.AssertAttribute <OperationContractAttribute>(method); Assert.AreEqual <string>(oc.ReplyAction, operation.ReplyAction); }
private ServiceContract CreateServiceContract( ServiceContractModel model, string serviceContractName, string operationName, string requestName, string responseName) { ServiceContract serviceContract = new ServiceContract(Store); serviceContract.ServiceContractModel = model; serviceContract.Name = serviceContractName; WCFServiceContract serviceContractExtender = new WCFServiceContract(); serviceContractExtender.ModelElement = serviceContract; serviceContract.ObjectExtender = serviceContractExtender; Operation op1 = new Operation(Store); WCFOperationContract wcfOp1 = new WCFOperationContract(); op1.ObjectExtender = wcfOp1; op1.Name = operationName; op1.Action = operationName; op1.Request = string.IsNullOrEmpty(requestName) ? null : CreateMessageContract(requestName); op1.Response = string.IsNullOrEmpty(responseName) ? null : CreateMessageContract(responseName); op1.ServiceContract = serviceContract; return(serviceContract); }
public void TestReplyActionGeneration() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); Operation op1 = new Operation(Store); WCFOperationContract oc = new WCFOperationContract(); oc.ReplyAction = "foo"; op1.ObjectExtender = oc; op1.Name = "op1"; op1.ServiceContract = rootElement; string content = RunTemplate(rootElement); Type generatedType = CompileAndGetType(content); MethodInfo method = TypeAsserter.AssertMethod(op1.Name, generatedType); OperationContractAttribute operation = TypeAsserter.AssertAttribute<OperationContractAttribute>(method); Assert.AreEqual<string>(oc.ReplyAction, operation.ReplyAction); }
public void TestAsyncOperationGeneration() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); Operation op1 = new Operation(Store); WCFOperationContract wfcOperationContract = new WCFOperationContract(); wfcOperationContract.AsyncPattern = true; op1.ObjectExtender = wfcOperationContract; op1.Name = "op1"; op1.Action = "op1"; op1.ServiceContract = rootElement; string content = RunTemplate(rootElement); Type generatedType = CompileAndGetType(content); MethodInfo beginMethod = TypeAsserter.AssertMethod("Begin"+op1.Name, generatedType); Assert.AreEqual<int>(2, beginMethod.GetParameters().Length); Assert.AreEqual<string>("IAsyncResult", beginMethod.ReturnType.Name); MethodInfo endMethod = TypeAsserter.AssertMethod("End"+op1.Name, generatedType); Assert.AreEqual<int>(1, endMethod.GetParameters().Length); Assert.AreEqual<string>("Void", endMethod.ReturnType.Name); }
private ServiceContract CreateServiceContract( ServiceContractModel model,string serviceContractName, string operationName, string requestName, string responseName) { ServiceContract serviceContract = new ServiceContract(Store); serviceContract.ServiceContractModel = model; serviceContract.Name = serviceContractName; WCFServiceContract serviceContractExtender = new WCFServiceContract(); serviceContractExtender.ModelElement = serviceContract; serviceContract.ObjectExtender = serviceContractExtender; Operation op1 = new Operation(Store); WCFOperationContract wcfOp1 = new WCFOperationContract(); op1.ObjectExtender = wcfOp1; op1.Name = operationName; op1.Action = operationName; op1.Request = string.IsNullOrEmpty(requestName) ? null : CreateMessageContract(requestName); op1.Response = string.IsNullOrEmpty(responseName) ? null : CreateMessageContract(responseName); op1.ServiceContract = serviceContract; return serviceContract; }