public static CrmRentAccountResponse CreateNothingToPayResponseObject() { CrmRentAccountResponse crmRentAccountResponse = CreateRentAccountResponseObject(true); crmRentAccountResponse.value[0].housing_rent = "200.00"; return(crmRentAccountResponse); }
public void CheckResponseFormatForName() { var paymentReference = "12345"; var privacy = false; CrmRentAccountResponse crmRentAccountResponse = TestHelpers.CreateRentAccountResponseObject(true); RentAccountResponse rentAccountResponse = new RentAccountResponse { Name = "Bob Bobson" }; var response = CRMFactory.ToRentAccountResponse(paymentReference, crmRentAccountResponse, privacy); response.Name.Should().Equals(rentAccountResponse.Name); }
public void CheckResponseForToPayCalculationIsZero() { var paymentReference = "12345"; var privacy = false; CrmRentAccountResponse crmRentAccountResponse = TestHelpers.CreateNothingToPayResponseObject(); RentAccountResponse rentAccountResponse = new RentAccountResponse { ToPay = 0.00M }; var response = CRMFactory.ToRentAccountResponse(paymentReference, crmRentAccountResponse, privacy); response.ToPay.Should().Equals(rentAccountResponse.ToPay); }
public void ReturnsCorrectResponseWhenAccountDoesNotExist() { var paymentReference = "1234567"; var privacy = false; var token = "token"; var crmRentAccountResponse = new CrmRentAccountResponse { value = new List <CRMRentAccount>() }; _mockCrmTokenGateway.Setup(x => x.GetCRMToken()).ReturnsAsync(token); _mockCrmGateway.Setup(x => x.GetRentAccount(paymentReference, token)).ReturnsAsync(crmRentAccountResponse); var response = _classUnderTest.Execute(paymentReference, privacy); response.Result.Should().BeNull(); }
public void CheckResponseForToPayCalculation() { var paymentReference = "12345"; var privacy = false; var positiveBalance = true; CrmRentAccountResponse crmRentAccountResponse = TestHelpers.CreateRentAccountResponseObject(positiveBalance); RentAccountResponse rentAccountResponse = new RentAccountResponse { ToPay = 800.00M }; var response = CRMFactory.ToRentAccountResponse(paymentReference, crmRentAccountResponse, privacy); response.ToPay.Should().Equals(rentAccountResponse.ToPay); }
public void CheckResponseForNegativeCurrentBalanceAndArrears() { var paymentReference = "12345"; var privacy = false; var positiveBalance = false; CrmRentAccountResponse crmRentAccountResponse = TestHelpers.CreateRentAccountResponseObject(positiveBalance); RentAccountResponse rentAccountResponse = new RentAccountResponse { CurrentBalance = -123.45M, HasArrears = true }; var response = CRMFactory.ToRentAccountResponse(paymentReference, crmRentAccountResponse, privacy); response.CurrentBalance.Should().Equals(rentAccountResponse.CurrentBalance); response.HasArrears.Should().Equals(rentAccountResponse.HasArrears); }
public static CrmRentAccountResponse CreateRentAccountResponseObject(bool positiveBalance) { CrmRentAccountResponse crmRentAccountResponse = new CrmRentAccountResponse { value = new List <CRMRentAccount> { new CRMRentAccount { contact1_x002e_firstname = "Bob", contact1_x002e_lastname = "Bobson", contact1_x002e_address1_postalcode = "E8 1DY", contact1_x002e_hackney_responsible = "true", housing_anticipated = "200.00", housing_prop_ref = "1234567", housing_house_ref = "1234567", housing_cur_bal = positiveBalance ? "123.45" : "-123.45", housing_rent = "1000.00", housing_tag_ref = "12345/01" } } }; return(crmRentAccountResponse); }
public static RentAccountResponse ToRentAccountResponse(string paymentReference, CrmRentAccountResponse crmResponse, bool privacy) { var firstname = privacy ? PrivacyFormatting.GetPrivacyString(crmResponse.value[0].contact1_x002e_firstname) : crmResponse.value[0].contact1_x002e_firstname; var lastname = privacy ? PrivacyFormatting.GetPrivacyString(crmResponse.value[0].contact1_x002e_lastname) : crmResponse.value[0].contact1_x002e_lastname; var fullname = $"{firstname} {lastname}"; var currentBalance = decimal.Parse(crmResponse.value[0].housing_cur_bal); var toPay = decimal.Parse(crmResponse.value[0].housing_rent) - decimal.Parse(crmResponse.value[0].housing_anticipated); var rentAccountResponse = new RentAccountResponse { AccountNumber = paymentReference, Name = fullname, CurrentBalance = currentBalance > 0 ? currentBalance : currentBalance * -1, Rent = decimal.Parse(crmResponse.value[0].housing_rent), ToPay = toPay < 0 ? 0 : toPay, Benefits = decimal.Parse(crmResponse.value[0].housing_anticipated), HasArrears = decimal.Parse(crmResponse.value[0].housing_cur_bal) > 0, IsHackneyResponsible = bool.Parse(crmResponse.value[0].contact1_x002e_hackney_responsible), NextPayment = GetNextMondayFormatted(), Postcode = crmResponse.value[0].contact1_x002e_address1_postalcode, TenancyAgreementId = crmResponse.value[0].housing_tag_ref }; return(rentAccountResponse); }