예제 #1
0
        public void CreateButton_Click_UpdateNotActiveSaveError_Error()
        {
            // Arrange
            var layoutPlan = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var ecnErros = new List <ECNError>();

            ecnErros.Add(new ECNError(Enums.Entity.BlastAB, Enums.Method.Save, "errorMsg"));
            var ecnException = new ECNException(ecnErros);

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", userId: 0, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: new commEntities.BlastSMS()
            {
                CustomerID = 1
            }, saveECNException: ecnException, updateLayoutCampaignValue: -1, hfSelectedLayoutNOOPReply: string.Empty, noopRadioValue: string.Empty, triggerPlan: null);
            var error = "<br/>" + Enums.Entity.BlastAB + ": " + "errorMsg";

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

            // Assert
            _phError.Visible.ShouldBeTrue();
            _lblErrorMessage.Text.ShouldBe(error);
        }
예제 #2
0
        public void CreateButton_Click_UpdateNotActiveWithTriggerNOOPYesNOOPReply_NoErrors(int updateTriggerMessageMethodValue)
        {
            // Arrange
            var triggerTimeSpan = new TimeSpan(5, 3, 1, 0);
            var layoutPlan      = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var userId = 200;
            var blast  = new commEntities.BlastSMS()
            {
                CustomerID = 1
            };
            var triggerPlans = new commEntities.TriggerPlans()
            {
                BlastID = 0
            };

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", userId: userId, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: blast, triggerPlan: triggerPlans, noopRadioValue: "Y", hfSelectedLayoutNOOPReply: "10", triggerTimeSpan: triggerTimeSpan, updateTriggerMessageValue: updateTriggerMessageMethodValue);

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

            // Assert
            triggerPlans.ShouldSatisfyAllConditions(
                () => triggerPlans.Period.ShouldBe(Convert.ToDecimal(triggerTimeSpan.TotalDays)),
                () => triggerPlans.ActionName.ShouldBe("NO OPEN on " + LayoutName),
                () => triggerPlans.UpdatedUserID.ShouldBe(userId));
            _triggerPlanSaveMethodCallCount.ShouldBe(1);
            _phError.Visible.ShouldBeFalse();
        }
예제 #3
0
        public void CreateButton_Click_UpdateNotActiveNoTriggerNOOPYesNOOPReplyGetNOOPBlastError_Error()
        {
            // Arrange
            var layoutPlan = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var ecnErros = new List <ECNError>();

            ecnErros.Add(new ECNError(Enums.Entity.BlastAB, Enums.Method.Save, "GetNOOPBlast_Error"));
            var ecnException = new ECNException(ecnErros);

            _shimMessageTriggers.GetNOOPBlastFromControlsBlast = (b) => throw ecnException;
            var error = "<br/>" + Enums.Entity.BlastAB + ": " + "GetNOOPBlast_Error";
            var blast = new commEntities.BlastSMS()
            {
                BlastID = 1, CustomerID = 1
            };

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", userId: 0, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: blast, triggerPlan: null, noopRadioValue: "Y", hfSelectedLayoutNOOPReply: "10", updateTriggerMessageValue: 1);

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

            // Assert
            _phError.Visible.ShouldBeTrue();
            _lblErrorMessage.Text.ShouldBe(error);
        }
예제 #4
0
        public void CreateButton_Click_UpdateNotActiveNoTriggerNOOPYesNOOPReply_SaveCalled(int blastId)
        {
            // Arrange
            var layoutPlan = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var blast = new commEntities.BlastSMS()
            {
                BlastID = blastId, CustomerID = 1
            };

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", userId: 0, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: blast, triggerPlan: null, noopRadioValue: "Y", hfSelectedLayoutNOOPReply: "10", updateTriggerMessageValue: 1);

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

            // Assert
            _phError.Visible.ShouldBeFalse();
            var saveCallCount = blastId > -1 ? 1 : 0;

            if (blastId > -1)
            {
                _triggerPlanSaveMethodCallCount.ShouldBe(saveCallCount);
            }
        }
예제 #5
0
        public void CreateButton_Click_UpdateNotActive_LayoutPlansSaveCalled()
        {
            // Arrange
            var layoutTimeSpan = new TimeSpan(2, 5, 3, 0);
            var layoutPlan     = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var userId = 200;

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", layoutTimeSpan: layoutTimeSpan, userId: userId, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: new commEntities.BlastSMS()
            {
                CustomerID = 1
            }, updateLayoutCampaignValue: -1, hfSelectedLayoutNOOPReply: string.Empty, noopRadioValue: string.Empty, triggerPlan: null);

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

            // Assert
            layoutPlan.ShouldSatisfyAllConditions(
                () => layoutPlan.LayoutID.ShouldBe(int.Parse(HfSelectedLayoutTriggerValue)),
                () => layoutPlan.ActionName.ShouldBe(LayoutName),
                () => layoutPlan.Criteria.ShouldBe(CriteriaValue),
                () => layoutPlan.Period.ShouldBe(Convert.ToDecimal(layoutTimeSpan.TotalDays)),
                () => layoutPlan.UpdatedUserID.ShouldBe(userId),
                () => layoutPlan.GroupID.ShouldBe(0));
            _layoutPlanSaveMethodCallCount.ShouldBe(1);
        }
예제 #6
0
        public void CreateButton_Click_UpdateActiveWithTrigger_Errors()
        {
            // Arrange
            var layoutPlan = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var blast = new commEntities.BlastSMS()
            {
                CustomerID = 1
            };
            var triggerPlans = new commEntities.TriggerPlans()
            {
                BlastID = 0
            };

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", userId: 0, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: blast, triggerPlan: triggerPlans, noopRadioValue: "Y", hfSelectedLayoutNOOPReply: "10", updateTriggerMessageValue: 1, activeOrSentResult: true);
            var error = "<br/>" + Enums.Entity.LayoutPlans + ": " + "Triggers have already been sent.  Cannot update.";

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

            // Assert
            _phError.Visible.ShouldBeTrue();
            _lblErrorMessage.Text.ShouldBe(error);
        }
예제 #7
0
        public void CreateButton_Click_UpdateNotActiveWithTriggerNOOPYesNullNOOPReply_Error()
        {
            // Arrange
            var layoutPlan = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var blast = new commEntities.BlastSMS()
            {
                CustomerID = 1
            };
            var triggerPlans = new commEntities.TriggerPlans()
            {
                BlastID = 0
            };
            var error = "<br/>" + Enums.Entity.LayoutPlans + ": " + "Please select a No Open follow up message";

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", userId: 0, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: blast, triggerPlan: triggerPlans, noopRadioValue: "Y", hfSelectedLayoutNOOPReply: string.Empty, updateTriggerMessageValue: 1);

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

            // Assert
            _phError.Visible.ShouldBeTrue();
            _lblErrorMessage.Text.ShouldBe(error);
        }
예제 #8
0
        private static void SetupShims()
        {
            ShimLayoutPlans.GetByLayoutPlanIDInt32User = (i, user) =>
            {
                var plans = new EntitiesCommunicator.LayoutPlans();
                plans.BlastID  = 1;
                plans.LayoutID = 2;
                return(plans);
            };

            ShimCommunicator.AllInstances.UserSessionGet = communicator =>
            {
                var session = CreateEcnSession();
                return(session);
            };

            ShimMessageTriggers.AllInstances.MasterGet = triggers =>
            {
                var master = new ecn.communicator.MasterPages.Communicator();
                return(master);
            };

            ShimMessageTriggers.AllInstances.SetNoopControlStatusBoolean = (_, __) => { };

            ShimBlast.GetByBlastIDInt32UserBoolean = (i, user, arg3) =>
            {
                var blast = new EntitiesCommunicator.BlastLayout();
                blast.LayoutID      = 1;
                blast.EmailFromName = SampleEmailFromName;
                blast.EmailFrom     = SampleEmail;
                blast.EmailSubject  = SampleEmailSubject;
                return(blast);
            };

            ShimTriggerPlans.GetByRefTriggerIDInt32User = (_, __) =>
            {
                var plan = new EntitiesCommunicator.TriggerPlans();
                plan.BlastID = 1;
                return(plan);
            };

            ShimLayout.GetByLayoutIDInt32UserBoolean = (_, __, ___) =>
            {
                var layout = new EntitiesCommunicator.Layout();
                return(layout);
            };

            ShimCampaignItem.GetByBlastIDInt32UserBoolean = (i, user, arg3) =>
            {
                var campaignItem = new EntitiesCommunicator.CampaignItem();
                return(campaignItem);
            };
        }
예제 #9
0
        public void CreateButton_Click_UpdateNotActiveNoTriggerWrongSelectedValue_Error(string noopValue, string layoutNOOPReplyValue)
        {
            // Arrange
            var layoutPlan = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var blast = new commEntities.BlastSMS()
            {
                BlastID = 1, CustomerID = 1
            };
            var error = "<br/>" + Enums.Entity.LayoutPlans + ": " + "Please select a No Open follow up message";

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", userId: 0, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: blast, triggerPlan: null, noopRadioValue: noopValue, hfSelectedLayoutNOOPReply: layoutNOOPReplyValue, updateTriggerMessageValue: 1);

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

            // Assert
            _phError.Visible.ShouldBeTrue();
            _triggerPlanSaveMethodCallCount.ShouldBe(0);
            _lblErrorMessage.Text.ShouldBe(error);
        }
예제 #10
0
        public void CreateButton_Click_UpdateNotActiveWithTriggerNOOPNo_DeleteCalled()
        {
            // Arrange
            var layoutPlan = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var blast = new commEntities.BlastSMS()
            {
                CustomerID = 1
            };
            var triggerPlans = new commEntities.TriggerPlans()
            {
                BlastID = 0
            };

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", userId: 0, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: blast, triggerPlan: triggerPlans, noopRadioValue: "N", hfSelectedLayoutNOOPReply: string.Empty, updateTriggerMessageValue: 1);

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

            // Assert
            _triggerPlanDeleteMethodCallCount.ShouldBe(1);
        }
예제 #11
0
        private void InitCommonForTest_CreateButton_Click(int layoutPlaneId, commEntities.LayoutPlans layoutPlans, commEntities.BlastAbstract blastAbstract, commEntities.TriggerPlans triggerPlan, string noopRadioValue, string hfSelectedLayoutNOOPReply, TimeSpan triggerTimeSpan = default(TimeSpan), ECNException saveECNException = null, int updateLayoutCampaignValue = 10, ECNException triggerPlanSaveException = null, int updateTriggerMessageValue = -1, bool activeOrSentResult = false, string eventTypeSelectedItem = "subscribe")
        {
            var criteriaDropDownList = new DropDownList();

            criteriaDropDownList.Items.Add(new ListItem()
            {
                Value = CriteriaValue, Selected = true
            });
            var noopRadioLst = new RadioButtonList();

            noopRadioLst.Items.Add(noopRadioValue);
            noopRadioLst.SelectedIndex = 0;
            var hfSelectedLayoutNOOPReplay = new HiddenField()
            {
                Value = hfSelectedLayoutNOOPReply
            };
            var eventTypeDropDown = new DropDownList();

            eventTypeDropDown.Items.Add(eventTypeSelectedItem);
            eventTypeDropDown.SelectedIndex = 0;
            ShimMessageTriggers.AllInstances.LayoutPlanIDGet = (s) => layoutPlaneId;
            ShimMessageTriggers.AllInstances.UpdateLayoutCampaignBlastInt32 = (m, b, i) => updateLayoutCampaignValue;
            _shimMessageTriggers.UpdateTriggerMessageBlastInt32             = (b, id) => updateTriggerMessageValue;
            ShimLayoutPlans.GetByLayoutPlanIDInt32User = (id, user) => layoutPlans;
            ShimLayoutPlans.SaveLayoutPlansUser        = (l, user) =>
            {
                _layoutPlanSaveMethodCallCount++;
                if (saveECNException != null)
                {
                    throw saveECNException;
                }
                return(0);
            };
            ShimBlast.GetByBlastIDInt32UserBoolean             = (id, user, b) => blastAbstract;
            ShimBlast.GetByCampaignItemBlastIDInt32UserBoolean = (c, u, b) => blastAbstract;
            ShimBlast.ActiveOrSentInt32Int32            = (bId, cId) => activeOrSentResult;
            ShimTriggerPlans.GetByRefTriggerIDInt32User = (i, u) => triggerPlan;
            ShimTriggerPlans.SaveTriggerPlansUser       = (t, u) =>
            {
                _triggerPlanSaveMethodCallCount++;
                if (triggerPlanSaveException != null)
                {
                    throw triggerPlanSaveException;
                }
                return(0);
            };
            _messageTriggersPrivateObject.SetField("_criteria", BindingFlags.Instance | BindingFlags.NonPublic, criteriaDropDownList);
            _messageTriggersPrivateObject.SetField("_layoutName", BindingFlags.Instance | BindingFlags.NonPublic, new TextBox()
            {
                Text = LayoutName
            });
            _messageTriggersPrivateObject.SetField("NOOP_RadioList", BindingFlags.Instance | BindingFlags.NonPublic, noopRadioLst);
            _messageTriggersPrivateObject.SetField("hfSelectedLayoutNOOPReply", BindingFlags.Instance | BindingFlags.NonPublic, hfSelectedLayoutNOOPReplay);
            _messageTriggersPrivateObject.SetField("NOOP_Period", BindingFlags.Instance | BindingFlags.NonPublic, new TextBox()
            {
                Text = triggerTimeSpan.Days.ToString()
            });
            _messageTriggersPrivateObject.SetField("NOOP_txtHours", BindingFlags.Instance | BindingFlags.NonPublic, new TextBox()
            {
                Text = triggerTimeSpan.Hours.ToString()
            });
            _messageTriggersPrivateObject.SetField("NOOP_txtMinutes", BindingFlags.Instance | BindingFlags.NonPublic, new TextBox()
            {
                Text = triggerTimeSpan.Minutes.ToString()
            });
            _messageTriggersPrivateObject.SetField("EventType", BindingFlags.Instance | BindingFlags.NonPublic, eventTypeDropDown);
        }
예제 #12
0
 private void InitTest_CreateButton_Click(string createBtnText, int userId, int layoutPlaneId, commEntities.LayoutPlans layoutPlans, commEntities.BlastAbstract blastAbstract, commEntities.TriggerPlans triggerPlan, string noopRadioValue, string hfSelectedLayoutNOOPReply, TimeSpan layoutTimeSpan = default(TimeSpan), TimeSpan triggerTimeSpan = default(TimeSpan), ECNException saveECNException = null, int updateLayoutCampaignValue = 10, ECNException triggerPlanSaveException = null, int updateTriggerMessageValue = -1, bool activeOrSentResult = false, string eventTypeSelectedItem = "subscribe")
 {
     InitMainForTest_CreateButton_Click(createBtnText: createBtnText, userId: userId, layoutTimeSpan: layoutTimeSpan);
     InitCommonForTest_CreateButton_Click(layoutPlaneId: layoutPlaneId, layoutPlans: layoutPlans, blastAbstract: blastAbstract, triggerPlan: triggerPlan, noopRadioValue: noopRadioValue, hfSelectedLayoutNOOPReply: hfSelectedLayoutNOOPReply, triggerTimeSpan: triggerTimeSpan, saveECNException: saveECNException, updateLayoutCampaignValue: updateLayoutCampaignValue, triggerPlanSaveException: triggerPlanSaveException, updateTriggerMessageValue: updateTriggerMessageValue, activeOrSentResult: activeOrSentResult, eventTypeSelectedItem: eventTypeSelectedItem);
 }