예제 #1
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
        public void API_BudgetStressAPISuccessCalls(string strURL, System.Net.HttpStatusCode HTTPStatusCode, float Price, float Deposit, float MonthlySavings, float MonthlyRent, int MortgageTerm, bool PassedStressTest, decimal StressAmount, decimal StressRate)
        {
            var testData = new StressBudget();
            testData.Price = Price;
            testData.Deposit = Deposit;
            testData.MonthlySavings = MonthlySavings;
            testData.MonthlyRent = MonthlyRent;
            testData.MortgageTerm = MortgageTerm;

            RestClient API_client = new RestClient();
            var client = API_client.client("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
            // is the server available??
            var rClient = client.PostAsJsonAsync<StressBudget>("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL, testData);
            HttpResponseMessage httpResponse = rClient.Result;

            var sTest = httpResponse.Content.ReadAsAsync<BudgetStressResponse>();
            var testDataResult = sTest.Result;

            AssertAll.Execute(
            () => Assert.IsTrue(httpResponse.StatusCode == System.Net.HttpStatusCode.OK, "Expected HTTP Code 200 OK but instead found " + httpResponse.StatusCode),
            () => Assert.IsTrue(testDataResult.PassedStressTest == PassedStressTest, "Expected PassedStressTest value of " + PassedStressTest + " but found " + testDataResult.PassedStressTest),
            () => Assert.IsTrue(testDataResult.StressAmount == StressAmount, "Expected Stress Amount to be " + StressAmount + " but found " + testDataResult.StressAmount),
            () => Assert.IsTrue(testDataResult.StressRate == StressRate, "Expected Stress Rate Amount of " + StressRate + " but found " + testDataResult.StressRate)
            );
        }
예제 #2
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
        public void API_BudgetStressAPIBadRequestCalls(string strURL, System.Net.HttpStatusCode HTTPStatusCode, float Price, float Deposit, float MonthlySavings, float MonthlyRent, int MortgageTerm, string ContainsErrorMsg1, string ContainsErrorMsg2, string ContainsErrorMsg3)
        {
            var testData = new StressBudget();
            testData.Price = Price;
            testData.Deposit = Deposit;
            testData.MonthlySavings = MonthlySavings;
            testData.MonthlyRent = MonthlyRent;
            testData.MortgageTerm = MortgageTerm;

            RestClient API_client = new RestClient();
            var client = API_client.client("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
            // is the server available??
            var rClient = client.PostAsJsonAsync<StressBudget>("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL, testData);
            HttpResponseMessage httpResponse = rClient.Result;

            var sTest = httpResponse.Content.ReadAsStringAsync();

            var testDataResult = sTest.Result;
            AssertAll.Execute(
            () => Assert.IsTrue(httpResponse.StatusCode == System.Net.HttpStatusCode.BadRequest, "Expected HTTP Code 400 BadRequest but instead found " + httpResponse.StatusCode),
            () => Assert.IsTrue(testDataResult.ToString().Contains(ContainsErrorMsg1) == true, "Expected Error Message Containing value of " + ContainsErrorMsg1 + " but error found instead is " + testDataResult),
            () => Assert.IsTrue(testDataResult.ToString().Contains(ContainsErrorMsg2) == true, "Expected Error Message Containing value of " + ContainsErrorMsg2 + " but error found instead is " + testDataResult)
            //            () => Assert.IsTrue(testDataResult.StressRate == StressRate, "Expected Stress Rate Amount of " + StressRate + " but found " + testDataResult.StressRate)
            );
        }