Пример #1
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);
        }
Пример #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_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);
        }
Пример #4
0
        public void CreateButton_Click_UpdateNotActiveWithTriggerNOOPYesNOOPReplyGetNOOPBlastError_Error()
        {
            // Arrange
            var layoutPlan = new commEntities.LayoutPlans()
            {
                BlastID = 0
            };
            var blast = new commEntities.BlastSMS()
            {
                CustomerID = 1
            };
            var triggerPlans = new commEntities.TriggerPlans()
            {
                BlastID = 0
            };
            var ecnErros = new List <ECNError>();

            ecnErros.Add(new ECNError(Enums.Entity.BlastAB, Enums.Method.Save, "GetNOOPBlast_Error"));
            var ecnException = new ECNException(ecnErros);
            var error        = "<br/>" + Enums.Entity.BlastAB + ": " + "GetNOOPBlast_Error";

            InitTest_CreateButton_Click(createBtnText: "Update Trigger", userId: 0, layoutPlaneId: 0, layoutPlans: layoutPlan, blastAbstract: blast, triggerPlan: triggerPlans, noopRadioValue: "Y", hfSelectedLayoutNOOPReply: "10", updateTriggerMessageValue: 1);
            _shimMessageTriggers.GetNOOPBlastFromControlsBlast = (b) => throw ecnException;

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

            // Assert
            _phError.Visible.ShouldBeTrue();
            _lblErrorMessage.Text.ShouldBe(error);
        }
Пример #5
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);
            };
        }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
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);
 }