public void Validate_DpaCheckPasses_ReturnsResultIsSucessfulTrue() { var dto = new RegisterValidationDto(); _mockDpaCheckProcess.Setup(x => x.CheckDataProtection(It.IsAny <RegisterValidationDto>())).ReturnsAsync(true); var result = _registerService.CheckDataProtectionAsync(dto); Assert.IsTrue(result.Result.IsSuccessful); }
public void Validate_DpaCheckFails_ReturnsResultIsSucessfulFalse() { var dto = new RegisterValidationDto(); _mockDpaCheckProcess.Setup(x => x.CheckDataProtection(It.IsAny <RegisterValidationDto>())).ReturnsAsync(false); var result = _registerService.CheckDataProtectionAsync(dto); Assert.IsFalse(result.Result.IsSuccessful); Assert.AreEqual(ValidationMessages.DataProtectionCheckFailed, result.Result.MessageForUser); }
public async Task <ResultDto> CheckDataProtectionAsync(RegisterValidationDto model) { var result = new ResultDto(); if (await _checkDataProtectionProcess.CheckDataProtection(model)) { result.IsSuccessful = true; } else { result.IsSuccessful = false; result.MessageForUser = ValidationMessages.DataProtectionCheckFailed; return(result); } return(result); }
public async Task <bool> CheckDataProtection(RegisterValidationDto dto) { var result = await _caseflowApiProxy.CheckDataProtection(dto); if (result == null) { //If account does not exist will return null. return(false); } if (String.Equals(result.Postcode.Replace(" ", ""), dto.Postcode.Replace(" ", ""), StringComparison.OrdinalIgnoreCase) && result.DateOfBirth == dto.DateOfBirth.ToString("yyyy-MM-dd") && result.LowellReference == dto.LowellReference) { return(true); } return(false); }
public void ValidateDpa_WhenCheckDpaReturnsNull_ReturnsTrue() { var dto = new RegisterValidationDto() { DateOfBirth = DateTime.Parse("1985-11-10"), LowellReference = "100262575", Postcode = "LS01 0NE" }; var model = new RecievedAccountDto(); model = null; _mockCaseflowApiProxy.Setup(x => x.CheckDataProtection(dto)).ReturnsAsync(model); var result = _checkDataProtectionProcess.CheckDataProtection(dto).Result; Assert.IsFalse(result); }
public async Task <RecievedAccountDto> CheckDataProtection(RegisterValidationDto dto) { string uri = $"v1/accounts/{Uri.EscapeDataString(dto.LowellReference)}"; try { var accountDto = await GetResultAsync <RecievedAccountDto>(uri); return(accountDto); } catch (ProxyException ex) { if (ex.StatusCode == HttpStatusCode.NotFound) { //When caseflow is unable to find lowell reference, null is returned. return(null); } throw; } }
public async Task <IActionResult> CheckDataProtection([FromBody] RegisterValidationDto model) { var result = await _registerService.CheckDataProtectionAsync(model); return(Ok(result)); }