예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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));
        }
예제 #3
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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"));
            }
        }
예제 #8
0
        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);
        }
예제 #9
0
        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();
            }
        }
예제 #10
0
        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();
            }
        }