Inheritance: StatusResponse
Beispiel #1
0
        private async Task <Result <FeeResponse, ErrorResponse> > getFeeAsync(ECurrency currency)
        {
            var    result     = new Result <FeeResponse, ErrorResponse>();
            string requestUri = $"{mEnv.BaseUrl}/v1/{currency}/Fee";

            try
            {
                using (HttpClient httpClient = new HttpClient())
                    using (HttpResponseMessage response = await httpClient.GetAsync(requestUri))
                    {
                        FeeResponse feeResponse = await response.Content.ReadAsAsync <FeeResponse>();

                        if (response.IsSuccessStatusCode)
                        {
                            result.IsSuccess = true;
                            result.Data      = feeResponse;

                            return(result);
                        }

                        string contentString = await response.Content.ReadAsStringAsync();

                        result.Error = ResponseHandler.GetError(response.StatusCode, requestUri, contentString);
                    }
            }
            catch (HttpRequestException)
            {
                result.IsSuccess = false;
                result.Error     = ResponseHandler.GetExceptionError();
            }
            return(result);
        }
        public void VerifyRegistrationFees(FeeResponse[] expectedResponse)
        {
            FeeResponse[] actualResponses = this.GetRegistrationFees();

            if (actualResponses.Length != expectedResponse.Length)
            {
                VerifyTool.VerifyValue(expectedResponse.Length, actualResponses.Length, "There are {0} fees");
            }
            else
            {
                for (int i = 0; i < actualResponses.Length; i++)
                {
                    if (!actualResponses.Equals(expectedResponse))
                    {
                        VerifyTool.VerifyValue(expectedResponse[i].FeeName, actualResponses[i].FeeName, "The fee name is {0}");
                        VerifyTool.VerifyValue(expectedResponse[i].FeeQuantity, actualResponses[i].FeeQuantity, "The fee quantity is {0}");
                        VerifyTool.VerifyValue(expectedResponse[i].FeeUnitPrice, actualResponses[i].FeeUnitPrice, "The fee unit price is {0}");
                        VerifyTool.VerifyValue(expectedResponse[i].FeeAmount, actualResponses[i].FeeAmount, "The fee amount is {0}");
                    }
                }
            }
        }
        public FeeResponse[] GetRegistrationFees()
        {
            string feeSummaryTableLocator = "//legend[text()='Fees']/../";
            List<FeeResponse> actResponse = new List<FeeResponse>();

            int count = UIUtil.DefaultProvider.GetXPathCountByXPath(feeSummaryTableLocator + "/tbody/tr");

            if (UIUtil.DefaultProvider.IsElementPresent(ConfirmationDiscountMessage, LocateBy.XPath))
            {
                count -= 3;//When there is a discount message, there are 3 summary rows
            }
            else
            {
                count -= 2;//When there is not a discount message, there are 2 summary rows
            }

            for (int i = 1; i < count; i++)
            {
                FeeResponse response = new FeeResponse();
                response.FeeName = UIUtil.DefaultProvider.GetText(string.Format(feeSummaryTableLocator + "/tbody/tr[{0}]/td", i + 1), LocateBy.XPath);
                response.FeeQuantity = UIUtil.DefaultProvider.GetText(string.Format(feeSummaryTableLocator + "/tbody/tr[{0}]/td[2]", i + 1), LocateBy.XPath);
                response.FeeUnitPrice = UIUtil.DefaultProvider.GetText(string.Format(feeSummaryTableLocator + "/tbody/tr[{0}]/td[3]", i + 1), LocateBy.XPath);
                response.FeeAmount = UIUtil.DefaultProvider.GetText(string.Format(feeSummaryTableLocator + "/tbody/tr[{0}]/td[4]", i + 1), LocateBy.XPath);
                actResponse.Add(response);
            }

            return actResponse.ToArray();
        }