public RequestTester(Action <HttpRequestMessage> assert = null, Action <IApiSettings> configure = null, Action <IEnumerable <Parameter>, RequestTransformContext> pipelineAction = null, DefaultApiSettings settings = null) { _settings = settings ?? new DefaultApiSettings(); _assert = assert ?? (a => { }); _configure = configure ?? (a => { }); _pipelineAction = pipelineAction ?? ((a, b) => { }); }
public async Task ParsingTheLocationHeaderFromResponseBodyViaCustomResponseParser() { var settings = new DefaultApiSettings(); var index = settings.Response.ResponseHandlers.FindIndex(x => x is AsyncDeserializingResponseHandler); settings.Response.ResponseHandlers[index] = new AsyncDeserializingResponseHandler(new HeaderEnabledContentDeserializer(new JsonSerializer())); var fakedResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(@"{id: 1, name: ""Mighty Gazelle""}", Encoding.UTF8, "application/json"), }; fakedResponse.Headers.Add("location", "api/customer/1"); var result = await GetResponse <ICustomerApi, Task <CustomerWithLocation> >( x => x.CreateCustomer(new Customer { Id = 1, Name = "Mighty Gazelle" }), fakedResponse, settings); Assert.Equal("Mighty Gazelle", result.Name); Assert.Equal("api/customer/1", result.Location); Assert.Equal(1, result.Id); }
public CountryRegionService(ICountryRegionService Provider = null) { if (Provider != null) { this.Provider = Provider; } else { var defaultApiSettings = new DefaultApiSettings(); if(defaultApiSettings.IsEnterprise) this.Provider = new SqlCountryRegionProvider(defaultApiSettings); else this.Provider = new ODataCountryRegionProvider(defaultApiSettings); } }
public ItemService(IItemService Provider = null) { if (Provider != null) { this.Provider = Provider; } else { var defaultApiSettings = new DefaultApiSettings(); if(defaultApiSettings.IsEnterprise) this.Provider = new SqlItemProvider(defaultApiSettings); else this.Provider = new ODataItemProvider(defaultApiSettings); } }
public AuthenticationService(IAuthenticationService Provider = null) { if (Provider != null) { this.Provider = Provider; } else { var defaultApiSettings = new DefaultApiSettings(); if(defaultApiSettings.IsEnterprise) this.Provider = new SqlAuthenticationProvider(defaultApiSettings); else this.Provider = new ODataAuthenticationProvider(defaultApiSettings); } }
public CustomerService(ICustomerService Provider = null) { if (Provider != null) { this.Provider = Provider; } else { var defaultApiSettings = new DefaultApiSettings(); if(defaultApiSettings.IsEnterprise) this.Provider = new SqlCustomerProvider(defaultApiSettings); else this.Provider = new ODataCustomerProvider(defaultApiSettings); } }
public AuthenticationService(IAuthenticationService Provider = null) { if (Provider != null) { this.Provider = Provider; } else { var defaultApiSettings = new DefaultApiSettings(); if (defaultApiSettings.IsEnterprise) { this.Provider = new SqlAuthenticationProvider(defaultApiSettings); } else { this.Provider = new ODataAuthenticationProvider(defaultApiSettings); } } }
public ItemService(IItemService Provider = null) { if (Provider != null) { this.Provider = Provider; } else { var defaultApiSettings = new DefaultApiSettings(); if (defaultApiSettings.IsEnterprise) { this.Provider = new SqlItemProvider(defaultApiSettings); } else { this.Provider = new ODataItemProvider(defaultApiSettings); } } }
public CommissionService(ICommissionService Provider = null) { if (Provider != null) { this.Provider = Provider; } else { var defaultApiSettings = new DefaultApiSettings(); if (defaultApiSettings.IsEnterprise) { this.Provider = new SqlCommissionProvider(defaultApiSettings); } else { this.Provider = new ODataCommissionProvider(defaultApiSettings); } } }
protected TReturn GetResponse <T, TReturn>(Func <T, TReturn> apiCall, HttpResponseMessage responseMessage, DefaultApiSettings settings = null) where T : class { var api = new ProxyGenerator().CreateInterfaceProxyWithoutTarget <T>(new FakeResponseCreator(responseMessage, settings)); return(apiCall(api)); }
protected void TestTheRequest <T>(Action <T> apiCall, Action <HttpRequestMessage> assertHttpRequestMessage, Action <IApiSettings> configure = null, Action <IEnumerable <Parameter>, RequestTransformContext> assertParametersAndContext = null, DefaultApiSettings settings = null) where T : class { var api = new ProxyGenerator().CreateInterfaceProxyWithoutTarget <T>(new RequestTester(assertHttpRequestMessage, configure, assertParametersAndContext, settings)); apiCall(api); }
protected void TestTheRequest <T>(Action <T> apiCall, Action <HttpRequestMessage> assertHttpRequestMessage, DefaultApiSettings settings = null) where T : class { var api = new ProxyGenerator().CreateInterfaceProxyWithoutTarget <T>(new InvocationTester(assertHttpRequestMessage, settings)); apiCall(api); }
public InvocationTester(Action <HttpRequestMessage> assert = null, DefaultApiSettings settings = null) { _settings = settings ?? new DefaultApiSettings(); _assert = assert ?? (a => { }); }