Пример #1
0
        public void Check_WithDto_WhenProxyResultIsSuccessful_ReturnsFalse()
        {
            Mock <IApiGatewayProxy> proxyMock = new Mock <IApiGatewayProxy>();

            // Contents don't matter for this test - just passes along to proxy
            DataProtectionDto dtoInput = new DataProtectionDto();

            var resultDto = new ResultDto()
            {
                IsSuccessful   = false,
                MessageForUser = "******"
            };

            proxyMock.Setup(x => x.CheckDataProtectionAnonymous(dtoInput)).Returns(Task.FromResult(resultDto));

            //
            // Test
            //
            CheckDataProtectionAnonymousProcess process = new CheckDataProtectionAnonymousProcess(proxyMock.Object);

            ResultDto result = process.CheckDataProtection(dtoInput).Result;

            Assert.AreEqual(false, result.IsSuccessful);
            Assert.AreEqual("wah", result.MessageForUser);

            proxyMock.Verify(x => x.CheckDataProtectionAnonymous(dtoInput), Times.Once);
        }
        public Task <ResultDto> CheckDataProtection(DataProtectionDto dataProtectionDto)
        {
            var uri = "api/register/CheckDataProtection";

            var result = _restClient.PostAsync <DataProtectionDto, ResultDto>($"{_portalSetting.GatewayEndpoint}{uri}", dataProtectionDto);

            return(result);
        }
        public DataProtectionDto Build(DataProtectionVm model)
        {
            // Before we reach this point, the incoming VM should have been validated
            Debug.Assert(model.DateOfBirth.HasValue);

            var dto = new DataProtectionDto
            {
                LowellReference = model.LowellReference,
                Postcode        = model.Postcode.ToUpper(),
                DateOfBirth     = model.DateOfBirth.Value
            };

            return(dto);
        }
        public async Task <ResultDto> CheckDataProtection(DataProtectionVm dataProtectionVm)
        {
            // VM will have been validated before we hit the service
            Debug.Assert(dataProtectionVm.DateOfBirth != null, "dataProtectionVm.DateOfBirth != null");

            DataProtectionDto dto = new DataProtectionDto()
            {
                LowellReference = dataProtectionVm.LowellReference,
                DateOfBirth     = dataProtectionVm.DateOfBirth.Value,
                Postcode        = dataProtectionVm.Postcode
            };

            return(await _checkDataProtectionAnonymousProcess.CheckDataProtection(dto));
        }
        public void Build_WhenCallWithValidModel_ConvertsIntoDto()
        {
            DataProtectionVm vm = new DataProtectionVm()
            {
                LowellReference = "123abc",
                Day             = 17,
                Month           = "September",
                Year            = 2018,
                Postcode        = "S4 7UL"
            };

            BuildDataProtectionDtoProcess process = new BuildDataProtectionDtoProcess(_mockLogger.Object);
            DataProtectionDto             dto     = process.Build(vm);

            Assert.AreEqual("123abc", dto.LowellReference);
            Assert.AreEqual(new DateTime(2018, 9, 17), dto.DateOfBirth);
            Assert.AreEqual("S4 7UL", dto.Postcode);
        }
        public void Build_WhenCallWithValidModel_ConvertsIntoDto_AndMakesPostCodeUpperCase()
        {
            // Converts postcode to upper case = to ensure correct for CaseFlow
            // Not good enough to just do on client as per user requirements

            DataProtectionVm vm = new DataProtectionVm()
            {
                LowellReference = "123abc",
                Day             = 17,
                Month           = "September",
                Year            = 2018,
                Postcode        = "s4 7ul"
            };

            BuildDataProtectionDtoProcess process = new BuildDataProtectionDtoProcess(_mockLogger.Object);
            DataProtectionDto             dto     = process.Build(vm);

            Assert.AreEqual("123abc", dto.LowellReference);
            Assert.AreEqual(new DateTime(2018, 9, 17), dto.DateOfBirth);
            Assert.AreEqual("S4 7UL", dto.Postcode);
        }
 public async Task <ResultDto> CheckDataProtection(DataProtectionDto dataProtectionDto)
 {
     return(await _apiGatewayProxy.CheckDataProtectionAnonymous(dataProtectionDto));
 }
        public async Task <ResultDto> CheckDataProtectionAnonymous(DataProtectionDto dto)
        {
            var innerUrl = $"{_baseUrl}api/DataProtection/CheckDataProtectionAnonymous";

            return(await _restClient.PostAsync <DataProtectionDto, ResultDto>(innerUrl, dto));
        }