/// <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 descriptor enum to the actual object. /// </summary> /// <param name="serviceDescriptorType">Service descriptor enum.</param> /// <returns>Corresponding service descriptor based on the provided enum.</returns> private static ServiceDescriptor GetServiceDescriptor( ServiceDescriptorType serviceDescriptorType) { switch (serviceDescriptorType) { case ServiceDescriptorType.AstoriaDefaultService: return(ServiceDescriptors.AstoriaDefaultService); case ServiceDescriptorType.PluggableFormatServiceDescriptor: return(ServiceDescriptors.PluggableFormatServiceDescriptor); case ServiceDescriptorType.TypeDefinitionServiceDescriptor: return(ServiceDescriptors.TypeDefinitionServiceDescriptor); case ServiceDescriptorType.ModelRefServiceDescriptor: return(ServiceDescriptors.ModelRefServiceDescriptor); case ServiceDescriptorType.OperationServiceDescriptor: return(ServiceDescriptors.OperationServiceDescriptor); case ServiceDescriptorType.TripPinServiceDescriptor: return(ServiceDescriptors.TripPinServiceDescriptor); case ServiceDescriptorType.ODataWCFServicePlusDescriptor: return(ServiceDescriptors.ODataWCFServicePlusDescriptor); case ServiceDescriptorType.ODataWCFServiceDescriptor: return(ServiceDescriptors.ODataWCFServiceDescriptor); case ServiceDescriptorType.AstoriaDefaultWithAccessRestrictions: return(ServiceDescriptors.AstoriaDefaultWithAccessRestrictions); case ServiceDescriptorType.PayloadValueConverterServiceDescriptor: return(ServiceDescriptors.PayloadValueConverterServiceDescriptor); case ServiceDescriptorType.PublicProviderEFService: return(ServiceDescriptors.PublicProviderEFService); case ServiceDescriptorType.PublicProviderHybridService: return(ServiceDescriptors.PublicProviderHybridService); case ServiceDescriptorType.ActionOverloadingService: return(ServiceDescriptors.ActionOverloadingService); case ServiceDescriptorType.OpenTypesService: return(ServiceDescriptors.OpenTypesService); case ServiceDescriptorType.UrlModifyingService: return(ServiceDescriptors.UrlModifyingService); case ServiceDescriptorType.ODataWriterService: return(ServiceDescriptors.ODataWriterService); case ServiceDescriptorType.PrimitiveKeysService: return(ServiceDescriptors.PrimitiveKeysService); case ServiceDescriptorType.KeyAsSegmentService: return(ServiceDescriptors.KeyAsSegmentService); case ServiceDescriptorType.AstoriaDefaultServiceModifiedClientTypes: return(ServiceDescriptors.AstoriaDefaultServiceModifiedClientTypes); case ServiceDescriptorType.PublicProviderReflectionService: return(ServiceDescriptors.PublicProviderReflectionService); case ServiceDescriptorType.ODataSimplifiedServiceDescriptor: return(ServiceDescriptors.ODataSimplifiedServiceDescriptor); default: throw new Exception(string.Format("Unsupported service descriptor type: {0}", serviceDescriptorType.ToString())); } }