public void Completed_BillingPreviewRun_Request_Should_Return_ResultFileUrl() { // Sample request id 2c92a0fd54cd2ff40154d0a2b6b97afc (this request should be completed) BillingPreviewRunResult result = BillingService.GetBillingRequestById("2c92a0fd54cd2ff40154d0a2b6b97afc"); // if there is no error message than submit successfully Assert.IsTrue(!string.IsNullOrWhiteSpace(result.ResultFileUrl)); }
public void Completed_BillingPreviewRun_Request_Should_Return_Completed_Status() { // Sample request id 2c92a0fd54cd2ff40154d0a2b6b97afc (this request is already completed) BillingPreviewRunResult result = BillingService.GetBillingRequestById("2c92a0fd54cd2ff40154d0a2b6b97afc"); // if there is no error message than submit successfully Assert.IsTrue(result.Status == "Completed"); }
private BillingPreviewRunResult SubmitBillingPreviewRequest(BillingPreviewRunInputs inputs) { BillingPreviewRunResult result = new BillingPreviewRunResult("Start", "", 0, DateTime.Now, "", ""); BillingPreviewRunService billingService = new BillingPreviewRunService(); bool loginSuccess = billingService.Login(inputs.UserId, inputs.Password); if (loginSuccess) { string requestId = ""; if (inputs.RequestId != "") { requestId = inputs.RequestId; } else { requestId = billingService.SubmitBillingPreviewRequest(inputs.TargetDate); } if (!string.IsNullOrWhiteSpace(requestId)) { // try 5 times to wait for the result. for (int i = 0; i < 10; i++) { // check for result result = billingService.GetBillingRequestById(requestId); // break if the request is complete if (result.Status == "Completed") { break; } // sleep 5 seconds Thread.Sleep(5000); } } else { return(new BillingPreviewRunResult("Error", "", 0, DateTime.Now, "Submit BillingPreviewRun request failed!", requestId)); } return(result); } else { return(new BillingPreviewRunResult("Error", "", 0, DateTime.Now, "Login failed! Check your credentials.", "")); } }