public void BtnSaveGateway_Click_Login(string id, bool isDeleted, bool isStatic, bool isNot)
        {
            // Arrange
            var gateway = new commEntities.Gateway()
            {
                GatewayID = SG_GatewayId
            };

            commEntities.GatewayValue gatewayValue = null;
            InitTestBtnSaveGatewayClick(selectedGroupId: "10", gatewayID: SG_GatewayId, gateway: gateway, chkLoginValidateCustom: true, chkLoginValidatePassword: true, loginOrCapture: "login");
            InitCustomValidateDT(idColumnValue: id, isDeletedColumnValue: isDeleted.ToString().ToLower(), isStaticColumnValue: isStatic.ToString().ToLower(), notColumnValue: isNot.ToString().ToLower());
            ShimGateway.SaveGatewayUser           = (g, u) => SG_GatewayId;
            ShimGatewayValue.SaveGatewayValueUser = (gwv, u) =>
            {
                gatewayValue = gwv;
                return(1);
            };

            // Act
            _gatewaySetupPrivateObject.Invoke("btnSaveGateway_Click", new object[] { null, null });

            // Assert
            if (id.Contains("-") && !isDeleted)
            {
                gatewayValue.ShouldSatisfyAllConditions(
                    () => _gatewayValueWipeOutValuesMethodCallCount.ShouldBe(1),
                    () => gatewayValue.IsLoginValidator.ShouldBeTrue(),
                    () => gatewayValue.Field.ShouldBe("Field"),
                    () => gatewayValue.Value.ShouldBe("Value"),
                    () => gatewayValue.Comparator.ShouldBe("Comparator"),
                    () => gatewayValue.NOT.ShouldBe(isNot),
                    () => gatewayValue.GatewayID.ShouldBe(SG_GatewayId),
                    () => gatewayValue.FieldType.ShouldBe("Type"),
                    () => gatewayValue.Label.ShouldBe("Label"),
                    () => gatewayValue.IsStatic.ShouldBe(isStatic));
            }
            else if (!id.Contains("-") && isDeleted)
            {
                _gatewayValueDeleteByIDMethodCallCount.ShouldBe(1);
            }
        }
Пример #2
0
 private void InitTestDisplayOrHide(out commEntities.Gateway gateway, bool forgotPasswordVisible = true, bool signupVisible = true, string styleSelectedValue = "default", string confirmationPage = "page", string loginOrCapture = "login")
 {
     gateway = new commEntities.Gateway()
     {
         GatewayID           = 10,
         ConfirmationMessage = DOH_ConfirmationMessage,
         ConfirmationText    = DOH_ConfirmationText,
         ForgotPasswordText  = DOH_ForgotPasswordText,
         ValidatePassword    = DOH_ValidatePassword,
         SignupText          = DOH_SignupText,
         SignupURL           = DOH_SignupURL,
         RedirectDelay       = DOH_RedirectDelay,
         Style       = DOH_Style,
         RedirectURL = DOH_RedirectURL
     };
     SetDisplayOrHideTest_PageControls();
     _gatewaySetupPrivateObject.SetField("DataFilePath", BindingFlags.Instance | BindingFlags.NonPublic, DOH_DataFilePath);
     _rblForgotPasswordVisible.Items.FindByValue(forgotPasswordVisible.ToString().ToLower()).Selected = true;
     _rblSignupVisible.Items.FindByValue(signupVisible.ToString().ToLower()).Selected = true;
     _rblStyling.Items.FindByValue(styleSelectedValue).Selected        = true;
     _rblConfirmationPage.Items.FindByValue(confirmationPage).Selected = true;
     _rblLoginOrCapture.Items.FindByValue(loginOrCapture).Selected     = true;
 }
        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"));
        }
 private void InitTestBtnSaveGatewayClick(string selectedGroupId, int gatewayID, commEntities.Gateway gateway, bool chkLoginValidatePassword = false, bool chkLoginValidateCustom = false, bool forgotPasswordVisible = true, bool signupVisible = true, string styleSelectedValue = "default", string confirmationPage = "page", string loginOrCapture = "login", string redirectDelayValue = "1")
 {
     SetBtnSaveGatewayClickTest_PageProperties(0);
     SetBtnSaveGatewayClickTest_PageControls();
     _hfSelectGroupID.Value = selectedGroupId;
     ShimGatewaySetup.AllInstances.GatewayIDGet = (gw) => gatewayID;
     ShimGateway.GetByGatewayIDInt32            = (id) => gateway;
     ShimGatewayValue.WipeOutValuesBooleanInt32 = (b, i) => _gatewayValueWipeOutValuesMethodCallCount++;
     ShimGatewayValue.DeleteByIDInt32           = (i) => _gatewayValueDeleteByIDMethodCallCount++;
     _txtGatewayName.Text        = SG_GatewayName;
     _txtGatewayPubCode.Text     = SG_GatewayPubCode;
     _txtGatewayTypeCode.Text    = SG_GatewayTypeCode;
     _txtGatewayHeader.Text      = SG_GatewayHeaderText;
     _txtGatewayFooter.Text      = SG_GatewayFooterText;
     _txtSubmitText.Text         = SG_SubmitText;
     _txtForgotPasswordText.Text = SG_ForgotPasswordText;
     _txtSignupText.Text         = SG_SignupText;
     _txtSignupURL.Text          = SG_SignupURLText;
     _txtStyle.Text = SG_StyleText;
     _txtConfirmationMessage.Text      = SG_ConfirmationMessageText;
     _txtConfirmationText.Text         = SG_ConfirmationText;
     _txtConfirmationRedirectURL.Text  = SG_ConfirmationRedirectURLText;
     _chkLoginValidateCustom.Checked   = chkLoginValidateCustom;
     _chkLoginValidatePassword.Checked = chkLoginValidatePassword;
     _gatewaySetupPrivateObject.SetField("DataFilePath", BindingFlags.Instance | BindingFlags.NonPublic, SG_DataFilePath);
     _ddlConfirmationRedirectDelay.Items.FindByValue(redirectDelayValue).Selected = true;
     _rblForgotPasswordVisible.Items.FindByValue(forgotPasswordVisible.ToString().ToLower()).Selected = true;
     _rblSignupVisible.Items.FindByValue(signupVisible.ToString().ToLower()).Selected = true;
     _rblStyling.Items.FindByValue(styleSelectedValue).Selected        = true;
     _rblConfirmationPage.Items.FindByValue(confirmationPage).Selected = true;
     _rblLoginOrCapture.Items.FindByValue(loginOrCapture).Selected     = true;
 }