/// <summary> /// Verifies that the arguments are valid and populates the serviceDescriptorType and /// serviceType parameters. /// </summary> /// <param name="serviceDescriptorType">Service wrapper type used to create service wrapper.</param> /// <param name="serviceType">Service wrapper type used to create service wrapper.</param> /// <returns>True if there's nothing wrong with the provided arguemnts; false otherwise.</returns> private static bool ParseServiceArguments( string[] args, out ServiceDescriptorType serviceDescriptorType, out ServiceType serviceType) { serviceDescriptorType = ServiceDescriptorType.Unknown; serviceType = ServiceType.Unknown; // Expect the first two arguments: // 1) Microsoft.Test.OData.Tests.Client.IPCCommandMap.ServiceDescriptorType enum // 2) Microsoft.Test.OData.Tests.Client.IPCCommandMap.ServiceType enum if (args.Length < 2) { return(false); } int serviceDescriptorTypeArg = 0; int serviceTypeArg = 0; if (!int.TryParse(args[0], out serviceDescriptorTypeArg) || !int.TryParse(args[1], out serviceTypeArg)) { return(false); } if (serviceDescriptorTypeArg >= (int)ServiceDescriptorType.Unknown || serviceTypeArg >= (int)ServiceType.Unknown) { return(false); } serviceDescriptorType = (ServiceDescriptorType)serviceDescriptorTypeArg; serviceType = (ServiceType)serviceTypeArg; return(true); }
/// <summary> /// Sets the service descriptor based on the provided ServiceDescriptorType enum and instantiates the /// service wrapper based on the ServiceType enum. The service is also started. /// </summary> /// <param name="serviceDescriptorType">Service descriptor enum to create corresponding service descriptor.</param> /// <param name="serviceType">Service type enum to create corresponding service wrapper.</param> private static void SetServiceDescriptorAndWrapper( ServiceDescriptorType serviceDescriptorType, ServiceType serviceType) { TestServiceUtil.ServiceUriGenerator = Microsoft.Test.OData.Tests.Client.ServiceGeneratorFactory.CreateServiceUriGenerator(); serviceDescriptor = GetServiceDescriptor(serviceDescriptorType); serviceWrapper = GetServiceWrapper(serviceType); }
/// <summary> /// Maps the service wrapper enum to the actual object. /// </summary> /// <param name="serviceType">Service enum.</param> /// <returns>Corresponding service wrapper based on the provided enum.</returns> private static IServiceWrapper GetServiceWrapper(ServiceType serviceType) { switch (serviceType) { case ServiceType.Default: return(new DefaultServiceWrapper(serviceDescriptor)); case ServiceType.WCF: return(new WCFServiceWrapper(serviceDescriptor)); default: throw new Exception(string.Format("Unsupported service type: {0}", serviceType.ToString())); } }