/// <summary> /// Instantiates and transmits all data to the middle tier web service that will execute the workflow /// </summary> /// <returns></returns> public virtual async Task <TDataOut> SendPutAsync <TDataIn, TDataOut>(Uri fullUrl, TDataIn itemToSend) { var returnValue = default(TDataOut); var request = new HttpRequestPut <TDataIn, TDataOut>(fullUrl, itemToSend); OnSendBegin(request); returnValue = await request.SendAsync(); OnSendEnd(request); return(returnValue); }
/// <summary> /// Creates an item in the system /// </summary> /// <param name="item"></param> /// <returns>Created item, with updated Id/Key (if applicable)</returns> public async Task <TDto> CreateAsync(TDto item) { TDto returnData; using (var client = new HttpRequestPut <TDto>(Uri, item)) { returnData = await client.SendAsync(); Response = client.Response; } return(await Task.Run(() => returnData)); }
public async Task Endpoints_WebApi_CustomerPut() { var customerToCreate = new CustomerModel(); var url = new Uri(new ConfigurationManagerLocal().AppSettingValue("MyWebService").AddLast("/Customer")); customerToCreate.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]); var request = new HttpRequestPut <CustomerModel>(url, customerToCreate); customerToCreate = await request.SendAsync(); Assert.IsTrue(interfaceBreakingRelease || !customerToCreate.IsNew); WebApiEndpointsTests.RecycleBin.Add(customerToCreate.Key); }
public async Task Endpoints_Framework_WebAPI_CustomerPut() { var customerToCreate = new CustomerModel(); var url = new Uri(new ConfigurationManagerFull().AppSettingValue("MyWebService").AddLast("/Customer")); customerToCreate.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]); var request = new HttpRequestPut <CustomerModel>(url, customerToCreate); customerToCreate = await request.SendAsync(); Assert.IsTrue(!customerToCreate.IsNew); Endpoints_Framework_for_WebApi.RecycleBin.Add(customerToCreate.ID); }
public async Task ViewModel_CRUD_Create() { var customer = new CustomerModel(); var url = new Uri(new ConfigurationManagerFull().AppSettingValue("MyWebService").AddLast("/Customer")); customer.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]); var request = new HttpRequestPut <CustomerModel>(url, customer); customer = await request.SendAsync(); Assert.IsTrue(customer.ID != TypeExtension.DefaultInteger); Assert.IsTrue(customer.Key != TypeExtension.DefaultGuid); recycleBin.Add(customer.ID); }
public async Task Customer_Cloud_CustomerPut() { CustomerModel customerToCreate = new CustomerModel(); string urlRoot = new ConfigurationManagerFull().AppSettingValue("MyWebService"); string urlFull = String.Format("{0}/{1}", urlRoot, "Customer"); HttpRequestPut <CustomerModel> request; // Simulate the service layer transforming the Model (CustomerModel) to the Data Access Object (CustomerInfo) customerToCreate.Fill(customerTestData[Arithmetic.Random(1, 5)]); // Call the cloud and get results request = new HttpRequestPut <CustomerModel>(urlFull, customerToCreate); customerToCreate = await request.SendAsync(); Assert.IsTrue(customerToCreate.ID != TypeExtension.DefaultInteger, "Customer did not save."); Assert.IsTrue(customerToCreate.Key != TypeExtension.DefaultGuid, "Customer did not save."); // Inserted records must be added to recycle bin for cleanup recycleBin.Add(customerToCreate.ID); }
public async Task Endpoints_Framework_WebAPI_CustomerPut() { var customerToCreate = new Customer(); var returnedItem = new Customer(); var url = new Uri(new ConfigurationManagerCore(ApplicationTypes.Native).AppSettingValue("MyWebService").AddLast("/Customer")); try { customerToCreate.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]); var request = new HttpRequestPut <Customer>(url, customerToCreate); returnedItem = await request.SendAsync(); Assert.IsTrue(interfaceBreakingRelease || customerToCreate != null); Endpoints_Framework_for_WebApi.RecycleBin.Add(customerToCreate.Key); } catch (HttpRequestException ex) { Assert.IsTrue(ex.Message.Contains("No such host") || ex.Message.Contains("no data")); } }
public async Task Core_ViewModel_CRUD_Create() { var customer = new CustomerModel(); var url = new Uri(new ConfigurationManagerCore(ApplicationTypes.Native).AppSettingValue("MyWebService").AddLast("/Customer")); try { customer.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]); var request = new HttpRequestPut <CustomerModel>(url, customer); customer = await request.SendAsync(); Assert.IsTrue(interfaceBreakingRelease | customer.Id != Defaults.Integer); Assert.IsTrue(interfaceBreakingRelease | customer.Key != Defaults.Guid); } catch (HttpRequestException ex) { Assert.IsTrue(ex.Message.Contains("No such host") || ex.Message.Contains("no data")); } RecycleBin.Add(customer.Key); }
public async Task Net_HttpRequestPut_SendAsync() { object dataOut = null; var configuration = ConfigurationManagerSafeTests.ConfigurationManagerSafeConstruct(); var request = new HttpRequestPut <object>(configuration.AppSettingValue("MyWebService") + "/HomeApi"); try { dataOut = await request.SendAsync(); Assert.IsTrue(request.Response.IsSuccessStatusCode); throw new WebException(); } catch (WebException) { Assert.IsTrue(dataOut != null); } finally { request.Dispose(); } }
public async Task Core_Net_HttpRequestPut_SendAsync() { object dataOut = null; var configuration = new ConfigurationManagerCore(ApplicationTypes.Native); var request = new HttpRequestPut <object>(new Uri(configuration.AppSettingValue("MyWebService") + "/HomeApi"), "This is a test"); try { dataOut = await request.SendAsync(); Assert.IsTrue(request.Response.IsSuccessStatusCode); throw new HttpRequestException(); } catch (HttpRequestException ex) { Assert.IsTrue(dataOut != null || ex.Message.Contains("No such host") || ex.Message.Contains("no data")); } finally { request.Dispose(); } }