public void SetECNError_Success_DetailsPanelIsShown() { // Arrange InitializeFakes(); InitilizeTestObject(); InitializePropertiesAndFields(); var error = new ECNError { ErrorMessage = DummyString }; var errorList = new List <ECNError> { error }; var ecnException = new ECNException(errorList); _methodArgs = new object[] { ecnException }; //Act CallMethod(typeof(emaileditor), MethodSetECNError, _methodArgs, _testObject); // Assert var ecnError = (GetField(_testObject, "lblErrorMessage") as Label).Text; var ecnErrorShown = (GetField(_testObject, "phError") as PlaceHolder).Visible; _testObject.ShouldSatisfyAllConditions( () => ecnError.ShouldContain(DummyString), () => ecnErrorShown.ShouldBeTrue()); }
private static void CreateWebShims() { HttpContext.Current = MockHelpers.FakeHttpContext(); ShimHttpApplication.AllInstances.ApplicationGet = (x) => HttpContext.Current.Application; ShimHttpApplication.AllInstances.RequestGet = (x) => HttpContext.Current.Request; ShimHttpApplication.AllInstances.ResponseGet = (x) => HttpContext.Current.Response; ShimHttpResponse.AllInstances.RedirectToRouteObject = (x, route) => { object routeObj = route; var routeStr = ""; routeStr += ReflectionHelper.GetPropertyValue(routeObj, "controller"); routeStr += ReflectionHelper.GetPropertyValue(routeObj, "action"); routeStr += ReflectionHelper.GetPropertyValue(routeObj, "message"); }; ShimHttpRequest.AllInstances.ServerVariablesGet = (x) => { var collection = new NameValueCollection(); collection.Add("HTTP_HOST", "testHost"); return(collection); }; ShimHttpRequest.AllInstances.UserAgentGet = (x) => "chrome"; ShimHttpServerUtility.AllInstances.GetLastError = (x) => { var sampleEcnErrorObject = new ECNError(); var sampleEcnErrorList = new List <ECNError>(); sampleEcnErrorList.Add(sampleEcnErrorObject); return(new ECNException(sampleEcnErrorList)); }; ShimHttpServerUtility.AllInstances.MapPathString = (x, y) => images_VirtualPath; }
public void SetEcnError_SetEcnExcpetion_SetsLblErrorMessageText() { // Arrange var testObject = new layoutExplorer(); var privateObject = new PrivateObject(testObject); var ecnError = new ECNError(Enums.Entity.APILogging, Enums.Method.Validate, ErrorMsg); var ecnExcpetion = new ECNException(new List <ECNError> { ecnError }); using (var placeHolder = new PlaceHolder { Visible = false }) { using (var label = new Label()) { privateObject.SetFieldOrProperty(PlaceHolderError, placeHolder); privateObject.SetFieldOrProperty(LabelErrorMessage, label); // Act privateObject.Invoke(SetEcnError, ecnExcpetion); // Assert testObject.ShouldSatisfyAllConditions( () => ((PlaceHolder)privateObject.GetFieldOrProperty(PlaceHolderError)).Visible.ShouldBeTrue(), () => ((Label)privateObject.GetFieldOrProperty(LabelErrorMessage)).Text. ShouldBe($"<br/>{ecnError.Entity}: {ecnError.ErrorMessage}")); } } }
public void BtnSaveGateway_Click_GateWayValueSaveError_Error(string loginOrCapture) { // Arrange ShimGateway.SaveGatewayUser = (g, u) => 1; var ecnError = new ECNError(Enums.Entity.GatewayValue, Enums.Method.Save, "saveGatewayValueError"); var expectedError = $"<br/>{Enums.Entity.GatewayValue}: saveGatewayValueError"; ShimGatewayValue.SaveGatewayValueUser = (gwv, u) => { throw new ECNException(new List <ECNError>() { ecnError }); }; InitTestBtnSaveGatewayClick(selectedGroupId: "10", gatewayID: 10, gateway: new commEntities.Gateway() { GatewayID = 10 }, chkLoginValidateCustom: true, chkLoginValidatePassword: true, loginOrCapture: loginOrCapture); if (loginOrCapture == "login") { InitCustomValidateDT(idColumnValue: "10-0", isDeletedColumnValue: "false", isStaticColumnValue: "false", notColumnValue: "false"); } else { InitCaptureCustomDT(idColumnValue: "10-0", isDeletedColumnValue: "false", isStaticColumnValue: "false"); } // Act _gatewaySetupPrivateObject.Invoke("btnSaveGateway_Click", new object[] { null, null }); // Assert _phError.ShouldSatisfyAllConditions( () => _phError.Visible.ShouldBeTrue(), () => _lblErrorMessage.Text.ShouldBe(expectedError)); }
private ECNException GetECNException() { var error = new ECNError { ErrorMessage = GetString(), Entity = Entity.BlastABMaster }; var errors = new List <ECNError> { error }; var exception = new ECNException(errors); return(exception); }
public void Save_WhenECNExceptionThrown_ShouldShowError() { //Arrange var error = new ECNError { ErrorMessage = GetString() }; var errors = new List <ECNError> { error }; _userSessionGetException = new ECNException(errors); var lblErrorMessage = GetReferenceField <Label>("lblErrorMessage"); //Act _page.Save(null, EventArgs.Empty); //Assert lblErrorMessage.Text.ShouldContain(error.ErrorMessage); }
public void PgeLoad_WhenECNExceptionThrown_ShouldShowError() { //Arrange var error = new ECNError { Entity = Enums.Entity.BlastAB, ErrorMessage = GetString() }; var errors = new List <ECNError> { error }; _linkTrackingParamGetByLinkTrackingIDException = new ECNException(errors); var lblErrorMessage = GetReferenceField <Label>("lblErrorMessage"); //Act CallPageLoad(); //Asssert lblErrorMessage.Text.ShouldBe($"<br/>{error.Entity}: {error.ErrorMessage}"); _phError.Visible.ShouldBeTrue(); }
public void BtnSaveGateway_Click_DifferentInitializers_GatewayInitializedWithProperValues(int gatewayId, bool forgotPasswordVisibile, bool signUpVisible, string selectedStyle, string selectedConfirmation, string loginOrCaptureValue) { // Arrange var gateway = new commEntities.Gateway() { GatewayID = gatewayId }; InitTestBtnSaveGatewayClick( selectedGroupId: "10", gatewayID: gatewayId, gateway: gateway, chkLoginValidateCustom: true, chkLoginValidatePassword: true, confirmationPage: selectedConfirmation, forgotPasswordVisible: forgotPasswordVisibile, loginOrCapture: loginOrCaptureValue, signupVisible: signUpVisible, styleSelectedValue: selectedStyle); var ecnError = new ECNError(Enums.Entity.Gateway, Enums.Method.Save, "saveGatewayError"); var expectedError = $"<br/>{Enums.Entity.Gateway}: saveGatewayError"; var expectedGatewayStyle = string.Empty; if (selectedStyle == "external") { expectedGatewayStyle = SG_StyleText; } else if (selectedStyle == "upload") { expectedGatewayStyle = $"{SG_DataFilePath}/{SG_StyleText}"; } var expectedUseRedirect = selectedConfirmation != "page"; var expectedUseConfirmation = selectedConfirmation != "pagewithredirect"; ShimGateway.SaveGatewayUser = (savedGateway, u) => { gateway = savedGateway; throw new ECNException(new List <ECNError>() { ecnError }); }; // Act _gatewaySetupPrivateObject.Invoke("btnSaveGateway_Click", new object[] { null, null }); // Assert _phError.ShouldSatisfyAllConditions( () => _phError.Visible.ShouldBeTrue(), () => _lblErrorMessage.Text.ShouldBe(expectedError), () => gateway.Name.ShouldBe(SG_GatewayName), () => gateway.CustomerID.ShouldBe(SG_CustomerID), () => gateway.GroupID.ShouldBe(10), () => gateway.PubCode.ShouldBe(SG_GatewayPubCode), () => gateway.TypeCode.ShouldBe(SG_GatewayTypeCode), () => gateway.Header.ShouldBe(SG_GatewayHeaderText), () => gateway.Footer.ShouldBe(SG_GatewayFooterText), () => gateway.SubmitText.ShouldBe(SG_SubmitText), () => gateway.ShowForgotPassword.ShouldBe(forgotPasswordVisibile), () => gateway.ForgotPasswordText.ShouldBe(forgotPasswordVisibile ? SG_ForgotPasswordText : string.Empty), () => gateway.ShowSignup.ShouldBe(signUpVisible), () => gateway.SignupText.ShouldBe(signUpVisible ? SG_SignupText : string.Empty), () => gateway.SignupURL.ShouldBe(signUpVisible ? SG_SignupURLText : string.Empty), () => gateway.UseStyleFrom.ShouldBe(selectedStyle), () => gateway.Style.ShouldBe(expectedGatewayStyle), () => gateway.ConfirmationMessage.ShouldBe(SG_ConfirmationMessageText), () => gateway.ConfirmationText.ShouldBe(selectedConfirmation == "page" ? string.Empty : SG_ConfirmationText), () => gateway.RedirectURL.ShouldBe(selectedConfirmation == "page" ? string.Empty : SG_ConfirmationRedirectURLText), () => gateway.RedirectDelay.ShouldBe(selectedConfirmation == "pagewithautoredirect" ? 1 : 0), () => gateway.LoginOrCapture.ShouldBe(loginOrCaptureValue), () => gateway.ValidateEmail.ShouldBe(loginOrCaptureValue == "login"), () => gateway.ValidatePassword.ShouldBe(loginOrCaptureValue == "login"), () => gateway.ValidateCustom.ShouldBe(loginOrCaptureValue == "login")); }