예제 #1
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
        public void API_SavingsAPINotFoundCalls(string strURL, System.Net.HttpStatusCode HTTPStatusCode, int Duration, bool BuyerType, decimal TargetPurchasePrice, decimal GiftAmount, decimal TargetDeposit, string TargetSavings, bool IsInvalid, string InvalidMessage)
        {
            var testData = new SavingsBudget();
            testData.Duration = Duration;
            testData.FirstTimeBuyer = BuyerType;
            testData.TargetPurchasePrice = TargetPurchasePrice;
            testData.GiftAmount = GiftAmount;
            testData.IsInvalid = IsInvalid;
            testData.InvalidMessage = InvalidMessage;

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

            AssertAll.Execute(
            () => Assert.IsTrue(httpResponse.StatusCode == System.Net.HttpStatusCode.OK, "Expected HTTP Code " + HTTPStatusCode + "  OK but instead found " + httpResponse.StatusCode),
            () => Assert.IsTrue(testDataResult.IsInvalid == IsInvalid, "Expected IsInvalid flag of " + IsInvalid + " but found " + testDataResult.IsInvalid),
            () => Assert.IsTrue(testDataResult.InvalidMessage == InvalidMessage, "Expected InvalidMessage of " + InvalidMessage + " but found " + testDataResult.InvalidMessage),
            () => Assert.IsTrue(testDataResult.Duration == testData.Duration, "Expected Duration of " + Duration + " but found " + testDataResult.Duration),
            () => Assert.IsTrue(testDataResult.FirstTimeBuyer == testData.FirstTimeBuyer, "Expected First time Buyer to be " + BuyerType + " but found " + testDataResult.FirstTimeBuyer),
            () => Assert.IsTrue(testDataResult.GiftAmount == testData.GiftAmount, "Expected Gift Amount of " + GiftAmount + " but found" + testDataResult.GiftAmount),
            () => Assert.IsTrue(testDataResult.TargetDeposit == TargetDeposit, "Expected TargetDeposit Amount of " + TargetDeposit + " but found " + testDataResult.TargetDeposit),
            () => Assert.IsTrue(testDataResult.TargetPurchasePrice == testData.TargetPurchasePrice, "Expected TargetPurchasePrice of " + TargetPurchasePrice + "but found " + testDataResult.TargetPurchasePrice),
            () => Assert.IsTrue(testDataResult.TargetSavings == Convert.ToDecimal(TargetSavings), "Expected TargetSavings Amount of " + Convert.ToDecimal(TargetSavings) + " but found " + testDataResult.TargetSavings)
            );
        }
예제 #2
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
 public void API_PropertySummarySuccess(string strURL, System.Net.HttpStatusCode HTTPStatusCode)
 {
     RestClient API_client = new RestClient();
     var client = API_client.client("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
     // is the server available??
     var rClient = client.GetAsync("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
     HttpResponseMessage httpResponse = rClient.Result;
     AssertAll.Execute(
         () => Assert.IsTrue(httpResponse.StatusCode == System.Net.HttpStatusCode.OK, "Expected HTTP Code 200 OK but instead found " + httpResponse.StatusCode),
         () => Assert.IsTrue(HTTPStatusCode == System.Net.HttpStatusCode.OK, "Test Data setup for a " + HTTPStatusCode + " check but executed result produced a " + httpResponse.StatusCode + " HTTP code.  Check test data is correct or API call has changed")
     );
 }
예제 #3
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
 public void API_PropertyDetailsFromAPICallsSearches(string strURL, System.Net.HttpStatusCode HTTPStatusCode)
 {
     RestClient API_client = new RestClient();
     var client = API_client.client("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
     // is the server available??
     var rClient = client.GetAsync("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
     HttpResponseMessage httpResponse = rClient.Result;
     var propertyUrl = "";
     PropertyDetails pdPropertyDetails = null;
     var PropertySearchResultAreaWrapper = httpResponse.Content.ReadAsAsync<PropertySearchResultAreaWrapper>();
     if (PropertySearchResultAreaWrapper.Result.SearchResults.Count() > 1)
     {
         Console.WriteLine("Found " + PropertySearchResultAreaWrapper.Result.SearchResults.Count() + " properties from the search");
         Console.WriteLine("Attempting to retrieve the first property from link " + PropertySearchResultAreaWrapper.Result.SearchResults[0].InfoLink.ToString());
         propertyUrl = PropertySearchResultAreaWrapper.Result.SearchResults[0].InfoLink.ToString();
         rClient = client.GetAsync(propertyUrl);
         httpResponse = rClient.Result;
         pdPropertyDetails = httpResponse.Content.ReadAsAsync<PropertyDetails>().Result;
         Console.WriteLine("Retrieved the first property with Id of " + pdPropertyDetails.Id + " at the following address " + pdPropertyDetails.FullAddress);
         AssertAll.Execute(
             () => Assert.IsTrue(httpResponse.StatusCode == System.Net.HttpStatusCode.OK, "Expected HTTP Code 200 OK but instead found " + httpResponse.StatusCode),
             () => Assert.IsTrue(HTTPStatusCode == System.Net.HttpStatusCode.OK, "Test Data setup for a " + HTTPStatusCode + " check but executed result produced a " + httpResponse.StatusCode + " HTTP code.  Check test data is correct or API call has changed"),
             () => Assert.IsTrue(pdPropertyDetails.Id != null, "Id was null but expected a value.  ID was" + pdPropertyDetails.Id),
             () => Assert.IsTrue(pdPropertyDetails.Type == "PropertyDetail", "Expected PropertyDetails.Type == \"PropertyDetail\" but found it was equal to " + pdPropertyDetails.Type + ".  Property Detail type has changed within the API."),
             () => Assert.IsTrue(pdPropertyDetails.County == "Co. Dublin", "Test Data setup for a " + HTTPStatusCode + " check but executed result produced a " + httpResponse.StatusCode + " HTTP code.  Check test data is correct or API call has changed"),
             () => Assert.IsTrue(PropertySearchResultAreaWrapper.Result.SearchResults.Count() > 0, "Test Data expected greater than 0 amount of records counted but found " + PropertySearchResultAreaWrapper.Result.SearchResults.Count() + " Properties count.  Check test data is correct or API call has changed, or possibly there have are not ANY properties.")
             );
     }
     else
     {
         Console.WriteLine("There were no properties returned Count is " + PropertySearchResultAreaWrapper.Result.SearchResults.Count() + " check the views are deployed and the API is up and available.");
         AssertAll.Execute(
             () => Assert.IsTrue(httpResponse.StatusCode == System.Net.HttpStatusCode.OK, "Expected HTTP Code 200 OK but instead found " + httpResponse.StatusCode),
             () => Assert.IsTrue(HTTPStatusCode == System.Net.HttpStatusCode.OK, "Test Data setup for a " + HTTPStatusCode + " check but executed result produced a " + httpResponse.StatusCode + " HTTP code.  Check test data is correct or API call has changed")
             );
     }
 }
예제 #4
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
 public void API_AmenityAPISuccessCalls(string strURL, System.Net.HttpStatusCode HTTPStatusCode, int AmenititesCount, string CoOrdNamedLocation)
 {
     RestClient API_client = new RestClient();
     var client = API_client.client("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
     // is the server available??
     var rClient = client.GetAsync("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
     HttpResponseMessage httpResponse = rClient.Result;
     var AmenititesResultEnvelope = httpResponse.Content.ReadAsAsync<AmenitiesResultEnvelope>();
     AssertAll.Execute(
         () => Assert.IsTrue(httpResponse.StatusCode == System.Net.HttpStatusCode.OK, "Expected HTTP Code 200 OK but instead found " + httpResponse.StatusCode),
         () => Assert.IsTrue(HTTPStatusCode == System.Net.HttpStatusCode.OK, "Test Data setup for a " + HTTPStatusCode + " check but executed result produced a " + httpResponse.StatusCode + " HTTP code.  Check test data is correct or API call has changed"),
         () => Assert.IsTrue(AmenititesResultEnvelope.Result.SearchResults.Count() == AmenititesCount, "Test Data expected " + AmenititesCount + " count but found " + AmenititesResultEnvelope.Result.SearchResults.Count() + " amenities count.  Check test data is correct or API call has changed, or possibly there have been new amenities been added to Geo Directory.")
         );
     Console.WriteLine("Found " + AmenititesResultEnvelope.Result.SearchResults.Count() + " amenities around " + CoOrdNamedLocation + " with filtered call as seen in URL " + strURL);
 }
예제 #5
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
 public void API_PropertyDetailsFromAmenitiesAPISearches(string strURL, System.Net.HttpStatusCode HTTPStatusCode)
 {
     RestClient API_client = new RestClient();
     var client = API_client.client("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
     // is the server available??
     var rClient = client.GetAsync("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
     HttpResponseMessage httpResponse = rClient.Result;
     PropertySearchResultAreaWrapper psrSearchResults = null;
     var AmenitiesResultEnvelope = httpResponse.Content.ReadAsAsync<AmenitiesResultEnvelope>();
     if (AmenitiesResultEnvelope.Result.SearchResults.Count() > 1)
     {
         Console.WriteLine("Found " + AmenitiesResultEnvelope.Result.SearchResults.Count() + " amenities from the search");
         Console.WriteLine("Attempting to retrieve the first property from link " + AmenitiesResultEnvelope.Result.SearchResults[0].InfoLink.ToString());
         //as we passed in the exact cords for this school amenity, school should be the first one in the result set, we should have a range of 0,
         //  ALWAYS, grab value to be validated at the end of the test.  Display Name should also match the expected school name.
         var ZeroRangeValueExpected = AmenitiesResultEnvelope.Result.SearchResults[0].Range;
         var SchoolNameExpected = AmenitiesResultEnvelope.Result.SearchResults[0].DisplayName;
         // This is the school we want to perform our property searches around, we will default to 1000M radius
         // and this means that the last property returned should ALWAYS have a range of less than 1001M from the school.
         var propertySearchURL = "looking/property/" + AmenitiesResultEnvelope.Result.SearchResults[0].Latitude + "/" + AmenitiesResultEnvelope.Result.SearchResults[0].Longitude + "/";
         rClient = client.GetAsync("http://homeappapihost-dev.elasticbeanstalk.com/" + propertySearchURL);
         httpResponse = rClient.Result;
         psrSearchResults = httpResponse.Content.ReadAsAsync<PropertySearchResultAreaWrapper>().Result;
         var propertyResultCount = psrSearchResults.SearchResults.Count();
         Console.WriteLine("Found " + psrSearchResults.SearchResults[propertyResultCount - 1].Range + " within 1000M of the school");
         AssertAll.Execute(
             () => Assert.IsTrue(ZeroRangeValueExpected == 0, "Expected 0 range value as school cords were used but value of " + ZeroRangeValueExpected + " was found for the range value"),
             () => Assert.IsTrue(SchoolNameExpected == "SCOIL OILIBHEÍR, DUBLIN HILL, CORK", "Expected Display Name to show SCOIL OILIBHEÍR, DUBLIN HILL, CORK but value of " + SchoolNameExpected + " was found for the Display Name value"),
             () => Assert.IsTrue(httpResponse.StatusCode == System.Net.HttpStatusCode.OK, "Expected HTTP Code 200 OK but instead found " + httpResponse.StatusCode),
             () => Assert.IsTrue(HTTPStatusCode == System.Net.HttpStatusCode.OK, "Test Data setup for a " + HTTPStatusCode + " check but executed result produced a " + httpResponse.StatusCode + " HTTP code.  Check test data is correct or API call has changed"),
             () => Assert.IsTrue(psrSearchResults.SearchResults[propertyResultCount - 1].Range < 1001, "Range should be within default range of 100M.  Range was " + psrSearchResults.SearchResults[propertyResultCount - 1].Range),
             () => Assert.IsTrue(AmenitiesResultEnvelope.Result.SearchResults.Count() > 0, "Test Data expected greater than 0 amount of records counted but found " + AmenitiesResultEnvelope.Result.SearchResults.Count() + " Properties count.  Check test data is correct or API call has changed, or possibly there have are not ANY properties.")
             );
     }
     else
     {
         Console.WriteLine("There were no properties returned Count is " + AmenitiesResultEnvelope.Result.SearchResults.Count() + " check the views are deployed and the API is up and available.");
         AssertAll.Execute(
             () => Assert.IsTrue(httpResponse.StatusCode == System.Net.HttpStatusCode.OK, "Expected HTTP Code 200 OK but instead found " + httpResponse.StatusCode),
             () => Assert.IsTrue(HTTPStatusCode == System.Net.HttpStatusCode.OK, "Test Data setup for a " + HTTPStatusCode + " check but executed result produced a " + httpResponse.StatusCode + " HTTP code.  Check test data is correct or API call has changed")
             );
     }
 }
예제 #6
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
        public void API_CheckListAPIReturned(string strURL, System.Net.HttpStatusCode HTTPStatusCode, string Id, string Type, string DisplayHeader, string IntroductionText, string FooterText)
        {
            var testData = new CheckList();
            testData.Id = Id;
            testData.Type = Type;
            testData.DisplayHeader = DisplayHeader;
            testData.IntroductionText = IntroductionText;
            testData.FooterText = FooterText;

            RestClient API_client = new RestClient();
            var client = API_client.client("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
            // is the server available??
            var rClient = client.GetAsync("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL); //, testData);
            HttpResponseMessage httpResponse = rClient.Result;
            //read Response as string as the response won't be JSON it will be a HTTP paged error
            var sTest = httpResponse.Content.ReadAsAsync<CheckList>();
            var testDataResult = sTest.Result;

            AssertAll.Execute(
            () => Assert.IsTrue(httpResponse.StatusCode == HTTPStatusCode, "Found this response " + testDataResult + " returned from API.  Expected HTTP code " + HTTPStatusCode + "  but instead found " + httpResponse.StatusCode),
            () => Assert.IsTrue(testDataResult.Id == testData.Id, "Expected Id of " + Id + " but found " + testDataResult.Id),
            () => Assert.IsTrue(testDataResult.Type == testData.Type, "Expected Type to be " + Type + " but found " + testDataResult.Type),
            () => Assert.IsTrue(testDataResult.DisplayHeader == testData.DisplayHeader, "Expected DisplayHeader of " + DisplayHeader + " but found" + testDataResult.DisplayHeader),
            () => Assert.IsTrue(testDataResult.IntroductionText == IntroductionText, "Expected IntroductionText of " + IntroductionText + " but found " + testDataResult.IntroductionText),
            () => Assert.IsTrue(testDataResult.FooterText == testData.FooterText, "Expected FooterText of " + FooterText + "but found " + testDataResult.FooterText) //,
            //() => Assert.IsTrue(testDataResult.TargetSavings == Convert.ToDecimal(TargetSavings), "Expected TargetSavings Amount of " + TargetSavings + " but found " + testDataResult.TargetSavings)
            );
        }
예제 #7
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
        public void API_StressAPINotFoundCallsNonJSONReturned(string strURL, System.Net.HttpStatusCode HTTPStatusCode, string JSONrequest)
        {
            var testData = JSONrequest;

            RestClient API_client = new RestClient();
            var client = API_client.client("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
            // is the server available??
            var rClient = client.PostAsJsonAsync("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.NotFound, "Found this response " + testDataResult + " returned from API.  Expected HTTP code " + HTTPStatusCode + "  but instead found " + httpResponse.StatusCode)//,
            );
        }
예제 #8
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)
            );
        }
예제 #9
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)
            );
        }
예제 #10
0
파일: Tests.cs 프로젝트: dermotKirk/HomeApp
        public void API_SavingsAPINotFoundCallsNonJSONReturned(string strURL, System.Net.HttpStatusCode HTTPStatusCode, string JSONrequest)
        {
            // assign the built up JSON that contains the bad request parameters
            var testData = JSONrequest;
            RestClient API_client = new RestClient();
            var client = API_client.client("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL);
            // is the server available??
            var rClient = client.PostAsJsonAsync("http://homeappapihost-dev.elasticbeanstalk.com/" + strURL, testData);
            HttpResponseMessage httpResponse = rClient.Result;
            //read Response as string as the response won't be JSON it will be a HTTP paged error
            var sTest = httpResponse.Content.ReadAsStringAsync();
            var testDataResult = sTest.Result;

            AssertAll.Execute(
            () => Assert.IsTrue(httpResponse.StatusCode == HTTPStatusCode, "Found this response " + testDataResult + " returned from API.  Expected HTTP code " + HTTPStatusCode + "  but instead found " + httpResponse.StatusCode)//,
            //() => Assert.IsTrue(testDataResult.Duration == testData.Duration, "Expected Duration of " + Duration + " but found " + testDataResult.Duration),
            //() => Assert.IsTrue(testDataResult.FirstTimeBuyer == testData.FirstTimeBuyer, "Expected First time Buyer to be " + BuyerType + " but found " + testDataResult.FirstTimeBuyer),
            //() => Assert.IsTrue(testDataResult.GiftAmount == testData.GiftAmount, "Expected Gift Amount of " + GiftAmount + " but found" + testDataResult.GiftAmount),
            //() => Assert.IsTrue(testDataResult.TargetDeposit == TargetDeposit, "Expected TargetDeposit Amount of " + TargetDeposit + " but found " + testDataResult.TargetDeposit),
            //() => Assert.IsTrue(testDataResult.TargetPurchasePrice == testData.TargetPurchasePrice, "Expected TargetPurchasePrice of " + TargetPurchasePrice + "but found " + testDataResult.TargetPurchasePrice),
            //() => Assert.IsTrue(testDataResult.TargetSavings == Convert.ToDecimal(TargetSavings), "Expected TargetSavings Amount of " + TargetSavings + " but found " + testDataResult.TargetSavings)
            );
        }