public void Feature_not_enabled_returns_is_valid_true() { var mockFeature = new Mock <IAllowedPostcodeFeature>(); mockFeature.Setup(f => f.IsEnabled).Returns(false); var sut = new PostCodeAllowedValidator(mockFeature.Object); Assert.IsTrue(sut.IsAllowedPostcode("SO30 2UN")); }
public void Feature_enabled_empty_postcode_list_returns_false() { var mockFeature = new Mock <IAllowedPostcodeFeature>(); mockFeature.Setup(f => f.IsEnabled).Returns(true); SetupMockCCGResultWithoutValidPostcode(); var sut = new PostCodeAllowedValidator(mockFeature.Object, mockCCGBuilder.Object); Assert.AreEqual(PostcodeValidatorResponse.PostcodeNotFound, sut.IsAllowedPostcode("SO30 2UN")); }
public void Feature_not_enabled_returns_is_valid_true() { var mockFeature = new Mock <IAllowedPostcodeFeature>(); mockFeature.Setup(f => f.IsEnabled).Returns(false); SetupMockCCGResultWithApp(); var sut = new PostCodeAllowedValidator(mockFeature.Object, mockCCGBuilder.Object); Assert.AreEqual(PostcodeValidatorResponse.InPathwaysArea, sut.IsAllowedPostcode("SO30 2UN")); }
public void Feature_enabled_missing_file_path_returns_false() { var mockFeature = new Mock <IAllowedPostcodeFeature>(); mockFeature.Setup(f => f.IsEnabled).Returns(true); SetupMockCCGResultWithoutApp(); var sut = new PostCodeAllowedValidator(mockFeature.Object, mockCCGBuilder.Object); Assert.AreEqual(PostcodeValidatorResponse.OutsidePathwaysArea, sut.IsAllowedPostcode("SO30 2UN")); }
public void Feature_enabled_missing_file_path_returns_false() { var mockFeature = new Mock <IAllowedPostcodeFeature>(); mockFeature.Setup(f => f.IsEnabled).Returns(true); mockFeature.Setup(f => f.PostcodeFile).Returns((TextReader.Null)); var sut = new PostCodeAllowedValidator(mockFeature.Object); Assert.IsFalse(sut.IsAllowedPostcode("SO30 2UN")); }
public void Feature_enabled_postcode_case_insensitive_returns_true() { var mockPostcodeList = new[] { "Postcode", "SO30 2UN" }; var mockFeature = new Mock <IAllowedPostcodeFeature>(); mockFeature.Setup(f => f.IsEnabled).Returns(true); mockFeature.Setup(f => f.PostcodeFile).Returns(new StringReader(string.Join(Environment.NewLine, mockPostcodeList))); var sut = new PostCodeAllowedValidator(mockFeature.Object); Assert.IsTrue(sut.IsAllowedPostcode("So30 2uN")); }
public void Feature_enabled_empty_postcode_list_returns_false() { var mockPostcodeList = @"Postcode"; var mockFeature = new Mock <IAllowedPostcodeFeature>(); mockFeature.Setup(f => f.IsEnabled).Returns(true); mockFeature.Setup(f => f.PostcodeFile).Returns(new StringReader(mockPostcodeList)); var sut = new PostCodeAllowedValidator(mockFeature.Object); Assert.IsFalse(sut.IsAllowedPostcode("SO30 2UN")); }
public void Feature_enabled_allowed_postcode_space_returns_true() { var mockPostcodeList = new[] { "Postcode", "SO30 2UN" }; SetupMockCCGResultWithApp(); var mockFeature = new Mock <IAllowedPostcodeFeature>(); mockFeature.Setup(f => f.IsEnabled).Returns(true); mockFeature.Setup(f => f.PostcodeFile).Returns(new StringReader(string.Join(Environment.NewLine, mockPostcodeList))); var sut = new PostCodeAllowedValidator(mockFeature.Object, mockCCGBuilder.Object); Assert.AreEqual(PostcodeValidatorResponse.InPathwaysArea, sut.IsAllowedPostcode("SO30 2UN")); }
public async Task <ActionResult> DispositionWithServices(OutcomeViewModel model, string submitAction, DosEndpoint?endpoint = null, DateTime?dosSearchTime = null) { ModelState.Clear(); if (submitAction == "manualpostcode") { return(View("../Outcome/ChangePostcode", model)); } var postcodeValidatorResponse = PostCodeAllowedValidator.IsAllowedPostcode(model.CurrentPostcode); if (postcodeValidatorResponse == PostcodeValidatorResponse.InvalidSyntax) { ModelState.AddModelError("CurrentPostcode", "Enter a valid postcode."); return(View("../Outcome/ChangePostcode", model)); } if (postcodeValidatorResponse == PostcodeValidatorResponse.PostcodeNotFound) { ModelState.AddModelError("CurrentPostcode", "We can't find any services in '" + model.CurrentPostcode + "'. Check the postcode is correct."); return(View("../Outcome/ChangePostcode", model)); } model = PopulateCCGAndStp(model); if (postcodeValidatorResponse == PostcodeValidatorResponse.PostcodeNotFound) { if (model.IsEmergencyPrescriptionOutcome) { return(View("../Pathway/EmergencyPrescriptionsOutOfArea", model)); } return(View("../Outcome/OutOfArea", model)); } var outcomeModel = await _outcomeViewModelBuilder.PopulateGroupedDosResults(model, dosSearchTime, null, endpoint).ConfigureAwait(false); var viewRouter = _viewRouter.Build(outcomeModel, ControllerContext); return(View(viewRouter.ViewName, outcomeModel)); }
public void EP_enabled_area_returns_pathway_with_pharmacy_area() { var mockPostcodeList = new[] { "Postcode", "SO30 2UN" }; mockCCGBuilder.Setup(f => f.FillCCGDetailsModelAsync(It.IsAny <string>())).ReturnsAsync(new CCGDetailsModel() { App = "Pathways", Postcode = "TS19 7TG", PharmacyReferralServiceIdWhitelist = new ServiceListModel("123|456") }); var mockFeature = new Mock <IAllowedPostcodeFeature>(); mockFeature.Setup(f => f.IsEnabled).Returns(true); mockFeature.Setup(f => f.PostcodeFile).Returns(new StringReader(string.Join(Environment.NewLine, mockPostcodeList))); var sut = new PostCodeAllowedValidator(mockFeature.Object, mockCCGBuilder.Object); Assert.AreEqual(PostcodeValidatorResponse.InPathwaysAreaWithPharmacyServices, sut.IsAllowedPostcode("So30 2uN")); }