Example #1
0
        protected override void SetPageSessionContext()
        {
            base.SetPageSessionContext();
            var sessionContainer = new HttpSessionStateContainer("id", new SessionStateItemCollection(),
                                                                 new HttpStaticObjectsCollection(), 10, true,
                                                                 HttpCookieMode.AutoDetect,
                                                                 SessionStateMode.InProc, false);
            var sessionState = typeof(HttpSessionState).GetConstructor(
                BindingFlags.NonPublic | BindingFlags.Instance,
                null, CallingConventions.Standard,
                new[] { typeof(HttpSessionStateContainer) },
                null)
                               .Invoke(new object[] { sessionContainer }) as HttpSessionState;

            ShimUserControl.AllInstances.SessionGet = (p) =>
            {
                return(sessionState);
            };
            _surveyReportInstance      = new SurveyReport();
            _shimSurveyReport          = new ShimSurveyReport(_surveyReportInstance);
            _surveyReportPrivateObject = new PrivateObject(_surveyReportInstance);
            InitializeAllControls(_surveyReportInstance);
            var shimEcnSession = new ShimECNSession();

            ShimECNSession.CurrentSession = () => shimEcnSession;
            ECNSession.CurrentSession().CurrentUser = new User()
            {
                UserID = 10
            };
            _viewState = GetPropertyOrField <StateBag>("ViewState");
        }
        private void SetupSqlFakes()
        {
            ShimSqlConnection.ConstructorString           = (_, __) => { };
            ShimSqlCommand.ConstructorStringSqlConnection = (_, __, ___) => { };
            ShimSqlDataAdapter.ConstructorSqlCommand      = (_, __) => { };
            ShimSqlConnection.AllInstances.Open           = _ => { };
            ShimSqlConnection.AllInstances.Close          = _ => { };

            ShimDbDataAdapter.AllInstances.FillDataSetString = (_, dataSet, srcTable) =>
            {
                if (srcTable.Equals(ProcGetGraphicalBlastReportData))
                {
                    dataSet.Tables.Add(GetGraphicalBlastReportDataTable());
                }
                else if (srcTable.Equals(ProcGetGraphicalBounceBlastReportData))
                {
                    dataSet.Tables.Add(GetGraphicalBlastBounceReportDataTable());
                }
                return(-1);
            };

            ShimPage.AllInstances.MasterGet = _ => new MasterPages.Communicator();
            ShimECNSession.CurrentSession   = () =>
            {
                ECNSession session = typeof(ECNSession).CreateInstance();
                session.CurrentUser = new User
                {
                    CustomerID = CustomerId
                };

                return(session);
            };
        }
        private void SetupFakes()
        {
            ShimUser.HasAccessUserEnumsServicesEnumsServiceFeaturesEnumsAccess = (_, __, ___, ____) => _hasAccess;

            ShimPage.AllInstances.MasterGet = _ => new ecn.communicator.MasterPages.Communicator();
            ShimECNSession.CurrentSession   = () =>
            {
                ECNSession session = typeof(ECNSession).CreateInstance();
                session.CurrentUser = new User
                {
                    CustomerID = CustomerId
                };

                return(session);
            };

            ShimSuppressedCodes.GetAll = () => new List <SuppressedCodes>
            {
                new SuppressedCodes
                {
                    SuppressedCodeID = SuppressedCodeID,
                    SupressedCode    = SupressedCode
                }
            };
        }
 private ecn.communicator.MasterPages.Communicator CreateCommunicatorObject(ECNSession ecnSession)
 {
     return(new ShimCommunicator
     {
         CurrentMenuCodeGet = () => { return MenuCode.OMNITURE; },
         CurrentMenuCodeSetEnumsMenuCode = (y) => { },
         UserSessionGet = () => { return ecnSession; }
     });
 }
 protected static void SetECNCurrentSession()
 {
     ShimECNSession.CurrentSession = () =>
     {
         var user = ReflectionHelper.CreateInstance(typeof(KMPlatform.Entity.User));
         user.UserID = 1;
         ECNSession ecnSession = ReflectionHelper.CreateInstance(typeof(ECNSession));
         ReflectionHelper.SetField(ecnSession, CurrentUser, user);
         ReflectionHelper.SetField(ecnSession, CustomerID, 1);
         ReflectionHelper.SetField(ecnSession, BaseChannelID, 1);
         return(ecnSession);
     };
 }
        public void CreateRecurring_WhenRecurrenceTypeWeeklyAndManualSlitAndAllNumberToSendAndBlastIdExists_UpdatesScheduleAndSetUpInfo()
        {
            // Arrange
            CreateTestData6();
            var sendDate = new DateTime(2018, 01, 01).ToShortDateString();

            _testEntity.Session[SessionRequestBlastIDKey] = 1;
            var blastSetupInfo = new BlastSetupInfo {
                BlastType = "ab"
            };
            var blastType = "ab";
            var param     = new object[]
            {
                blastSetupInfo,
                blastType
            };
            var ddlNumberToSendType = Get <DropDownList>(_privateTestObject, "ddlNumberToSendType");

            ddlNumberToSendType.Items.Add(new ListItem("ALL", "ALL")
            {
                Selected = true
            });

            // Act
            _privateTestObject.Invoke(CreateRecurringMethodName, param);

            // Assert
            _isScheduleUpdated.ShouldBeTrue();
            _isScheduleInserted.ShouldBeFalse();
            _savedSchedule.ShouldNotBeNull();
            _savedSchedule.ShouldSatisfyAllConditions(
                () => _savedSchedule.SchedStartDate.ShouldContain(sendDate),
                () => _savedSchedule.SchedEndDate.ShouldContain(Get <TextBox>(_privateTestObject, "txtEndDate").Text),
                () => _savedSchedule.Period.ShouldBe("w"),
                () => _savedSchedule.ErrorList.Count.ShouldBe(0),
                () => _savedSchedule.DaysList.Count.ShouldBe(7),
                () => _savedSchedule.DaysList[0].IsAmount.Value.ShouldBeFalse(),
                () => _savedSchedule.DaysList[0].DayToSend.Value.ShouldBe(6),
                () => _savedSchedule.DaysList[0].Total.Value.ShouldBe(7),
                () => _savedSchedule.CreatedBy.ShouldBe(ECNSession.CurrentSession().CurrentUser.UserID),
                () => _savedSchedule.UpdatedBy.ShouldBe(ECNSession.CurrentSession().CurrentUser.UserID));
            var refSetUpInfo = param[0] as BlastSetupInfo;

            refSetUpInfo.ShouldNotBeNull();
            refSetUpInfo.ShouldSatisfyAllConditions(
                () => refSetUpInfo.BlastFrequency.ShouldBe("RECURRING"),
                () => refSetUpInfo.BlastScheduleID.ShouldBe(1),
                () => refSetUpInfo.BlastType.ShouldBeNullOrWhiteSpace(),
                () => refSetUpInfo.ScheduleType.ShouldBe("Schedule Recurring"),
                () => refSetUpInfo.SendTime.Value.Date.ShouldBe(Convert.ToDateTime(sendDate)));
        }
        private static void SetupSessionFakes()
        {
            ShimECNSession.CurrentSession = () =>
            {
                ECNSession session = typeof(ECNSession).CreateInstance();

                Customer customer = typeof(Customer).CreateInstance();
                customer.CustomerID = CustomerId;

                session.SetField(nameof(ECNSession.CurrentCustomer), customer);

                return(session);
            };
        }
Example #8
0
        private static void SetupPageFakes()
        {
            ShimECNSession.CurrentSession = () =>
            {
                ECNSession session = typeof(ECNSession).CreateInstance();
                session.CurrentUser = new User
                {
                    CustomerID = CustomerId
                };

                return(session);
            };

            ShimPage.AllInstances.MasterGet = _ => new MasterPages.Communicator();
        }
        protected override void SetPageSessionContext()
        {
            base.SetPageSessionContext();
            _defineSurveyInstance      = new DefineSurvey();
            _shimDefineSurvey          = new ShimDefineSurvey(_defineSurveyInstance);
            _defineSurveyPrivateObject = new PrivateObject(_defineSurveyInstance);
            InitializeAllControls(_defineSurveyInstance);
            var shimEcnSession = new ShimECNSession();

            ShimECNSession.CurrentSession = () => shimEcnSession;
            ECNSession.CurrentSession().CurrentUser = new KMPlatform.Entity.User()
            {
                UserID = 10
            };
        }
        public void CreateRecurring_WhenRecurrenceTypeMonthlyAndMonthsMoreAndNoNumberToSend_InsertsScheduleAndSetUpInfo()
        {
            // Arrange
            CreateTestData4();
            var sendDate       = new DateTime(2018, 01, 01).ToShortDateString();
            var blastSetupInfo = new BlastSetupInfo {
                BlastType = "ab"
            };
            var blastType = "ab";
            var param     = new object[]
            {
                blastSetupInfo,
                blastType
            };

            Get <TextBox>(_privateTestObject, "txtMonth").Text = "33";
            Get <DropDownList>(_privateTestObject, "ddlNumberToSendType").Items.Clear();

            // Act
            _privateTestObject.Invoke(CreateRecurringMethodName, param);

            // Assert
            _isScheduleUpdated.ShouldBeFalse();
            _isScheduleInserted.ShouldBeTrue();
            _savedSchedule.ShouldNotBeNull();
            _savedSchedule.ShouldSatisfyAllConditions(
                () => _savedSchedule.SchedStartDate.ShouldContain(sendDate),
                () => _savedSchedule.SchedEndDate.ShouldBeNullOrWhiteSpace(),
                () => _savedSchedule.Period.ShouldBe("m"),
                () => _savedSchedule.ErrorList.Count.ShouldBe(0),
                () => _savedSchedule.DaysList.Count.ShouldBe(1),
                () => _savedSchedule.DaysList[0].IsAmount.Value.ShouldBeFalse(),
                () => _savedSchedule.DaysList[0].DayToSend.Value.
                ShouldBe(Convert.ToInt32(Get <TextBox>(_privateTestObject, "txtMonth").Text)),
                () => _savedSchedule.DaysList[0].Total.Value.ShouldBe(1),
                () => _savedSchedule.CreatedBy.ShouldBe(ECNSession.CurrentSession().CurrentUser.UserID),
                () => _savedSchedule.UpdatedBy.ShouldBe(ECNSession.CurrentSession().CurrentUser.UserID));
            var refSetUpInfo = param[0] as BlastSetupInfo;

            refSetUpInfo.ShouldNotBeNull();
            refSetUpInfo.ShouldSatisfyAllConditions(
                () => refSetUpInfo.BlastFrequency.ShouldBe("RECURRING"),
                () => refSetUpInfo.BlastScheduleID.ShouldBe(1),
                () => refSetUpInfo.BlastType.ShouldBeNullOrWhiteSpace(),
                () => refSetUpInfo.ScheduleType.ShouldBe("Schedule Recurring"),
                () => refSetUpInfo.SendTime.Value.Date.ShouldBe(Convert.ToDateTime(sendDate)));
        }
        private static ECNSession CreateEcnSession()
        {
            ECNSession session = typeof(ECNSession).CreateInstance();

            Customer customer = typeof(Customer).CreateInstance();

            customer.CustomerID = CustomerId;
            session.SetField(nameof(ECNSession.CurrentCustomer), customer);

            User user = typeof(User).CreateInstance();

            user.UserID     = UserId;
            user.CustomerID = CustomerId;
            session.SetField(nameof(ECNSession.CurrentUser), user);

            return(session);
        }
        public void CreateRecurring_WhenRecurrenceTypeMonthlyRequestBlastIdExistsAndBlastTypeSet_UpdatesScheduleAndSetUpInfo()
        {
            // Arrange
            CreateTestData3();
            var sendDate = new DateTime(2018, 01, 01).ToShortDateString();

            _testEntity.Session[SessionRequestBlastIDKey] = 1;
            var blastSetupInfo = new BlastSetupInfo
            {
                BlastType = "ab"
            };
            var blastType = "ab";
            var param     = new object[]
            {
                blastSetupInfo,
                blastType
            };

            // Act
            _privateTestObject.Invoke(CreateRecurringMethodName, param);

            // Assert
            _isScheduleUpdated.ShouldBeTrue();
            _isScheduleInserted.ShouldBeFalse();
            _savedSchedule.ShouldNotBeNull();
            _savedSchedule.ShouldSatisfyAllConditions(
                () => _savedSchedule.SchedStartDate.ShouldContain(sendDate),
                () => _savedSchedule.SchedEndDate.ShouldBeNullOrWhiteSpace(),
                () => _savedSchedule.Period.ShouldBe("m"),
                () => _savedSchedule.ErrorList.Count.ShouldBe(0),
                () => _savedSchedule.DaysList.Count.ShouldBe(1),
                () => _savedSchedule.DaysList[0].IsAmount.Value.ShouldBeTrue(),
                () => _savedSchedule.DaysList[0].DayToSend.Value.ShouldBe(1),
                () => _savedSchedule.DaysList[0].Total.Value.ShouldBe(1),
                () => _savedSchedule.CreatedBy.ShouldBe(ECNSession.CurrentSession().CurrentUser.UserID),
                () => _savedSchedule.UpdatedBy.ShouldBe(ECNSession.CurrentSession().CurrentUser.UserID));
            var refSetUpInfo = param[0] as BlastSetupInfo;

            refSetUpInfo.ShouldNotBeNull();
            refSetUpInfo.ShouldSatisfyAllConditions(
                () => refSetUpInfo.BlastFrequency.ShouldBe("RECURRING"),
                () => refSetUpInfo.BlastScheduleID.ShouldBe(1),
                () => refSetUpInfo.BlastType.ShouldBeNullOrWhiteSpace(),
                () => refSetUpInfo.ScheduleType.ShouldBe("Schedule Recurring"),
                () => refSetUpInfo.SendTime.Value.Date.ShouldBe(Convert.ToDateTime(sendDate)));
        }
        protected override void SetPageSessionContext()
        {
            base.SetPageSessionContext();
            _shimContext                 = ShimsContext.Create();
            _defineTemplateInstance      = new DefineTemplate();
            _shimDefineQuestions         = new ShimDefineTemplate(_defineTemplateInstance);
            _defineTemplatePrivateObject = new PrivateObject(_defineTemplateInstance);
            InitializeAllControls(_defineTemplateInstance);
            var shimEcnSession = new ShimECNSession();

            ShimECNSession.CurrentSession = () => shimEcnSession;
            ECNSession.CurrentSession().CurrentUser = new KMPlatform.Entity.User()
            {
                UserID = 10
            };
            InitControls();
            InitCommonShims();
        }
        private void SetFakesForInitializeMethod()
        {
            QueryString.Clear();
            QueryString.Add(SampleIDKey, "1");

            var settings = new NameValueCollection();

            settings.Add($"IgnoreSuppression_{ECNSession.CurrentSession().CurrentUser.UserID}", bool.TrueString);
            ShimConfigurationManager.AppSettingsGet = () => settings;

            ShimUser.HasAccessUserEnumsServicesEnumsServiceFeaturesEnumsAccess = (user, r, d, g) => true;
            ShimCampaign.GetByCustomerID_NonArchivedInt32UserBoolean           = (custId, user, b) => new List <CommunicatorEntities.Campaign>
            {
                new CommunicatorEntities.Campaign {
                    CampaignName = SampleCampaignName, CampaignID = 1
                }
            };
            ShimSample.GetBySampleIDInt32User             = (sampleId, user) => new CommunicatorEntities.Sample {
            };
            ShimCampaignItem.GetByBlastIDInt32UserBoolean = (bid, user, b) => new CommunicatorEntities.CampaignItem
            {
                CampaignID             = 1,
                CampaignItemID         = 1,
                CampaignItemName       = SampleCampaignName,
                CampaignItemTemplateID = 1,
                BlastField1            = "1",
                BlastField2            = "2",
                BlastField3            = "3",
                BlastField4            = "4",
                BlastField5            = "5",
            };
            ShimCampaignItem.GetByCampaignItemIDInt32UserBoolean = (cid, user, b) => new CommunicatorEntities.CampaignItem
            {
                CampaignID             = 1,
                CampaignItemName       = SampleCampaignItem,
                CampaignItemTemplateID = 1,
                IgnoreSuppression      = true
            };
            ShimCampaignItemTemplate.GetByCampaignItemTemplateIDInt32UserBoolean = (cid, user, b) => new CommunicatorEntities.CampaignItemTemplate();
            ShimBlastActivity.ChampionByProcInt32BooleanUserString = (sid, b, user, t) => GetActivityDataTable();
            ShimCustomer.HasProductFeatureInt32EnumsServicesEnumsServiceFeatures = (cid, s, f) => true;
        }
        public void CreateRecurring_WhenRecurrenceTypeDailyAndSingleNumberSendRequestBlastIdExists_UpdatesScheduleAndSetUpInfo()
        {
            // Arrange
            CreateTestData1();
            var blastSetupInfo = new BlastSetupInfo();
            var blastType      = string.Empty;
            var param          = new object[]
            {
                blastSetupInfo,
                blastType
            };
            var ddlNumberToSendType = Get <DropDownList>(_privateTestObject, "ddlNumberToSendType");

            ddlNumberToSendType.Items.Add(new ListItem("Number", "Number"));

            // Act
            _privateTestObject.Invoke(CreateRecurringMethodName, param);

            // Assert
            _isScheduleUpdated.ShouldBeTrue();
            _isScheduleInserted.ShouldBeFalse();
            _savedSchedule.ShouldNotBeNull();
            _savedSchedule.ShouldSatisfyAllConditions(
                () => _savedSchedule.SchedStartDate.ShouldContain(DateTime.Now.ToShortDateString()),
                () => _savedSchedule.SchedEndDate.ShouldBeNullOrWhiteSpace(),
                () => _savedSchedule.Period.ShouldBe("d"),
                () => _savedSchedule.ErrorList.Count.ShouldBe(0),
                () => _savedSchedule.DaysList.Count.ShouldBe(1),
                () => _savedSchedule.DaysList[0].IsAmount.Value.ShouldBeTrue(),
                () => _savedSchedule.CreatedBy.ShouldBe(ECNSession.CurrentSession().CurrentUser.UserID),
                () => _savedSchedule.UpdatedBy.ShouldBe(ECNSession.CurrentSession().CurrentUser.UserID));
            var refSetUpInfo = param[0] as BlastSetupInfo;

            refSetUpInfo.ShouldNotBeNull();
            refSetUpInfo.ShouldSatisfyAllConditions(
                () => refSetUpInfo.BlastFrequency.ShouldBe("RECURRING"),
                () => refSetUpInfo.BlastScheduleID.ShouldBe(1),
                () => refSetUpInfo.BlastType.ShouldBeNullOrWhiteSpace(),
                () => refSetUpInfo.ScheduleType.ShouldBe("Schedule Recurring"),
                () => refSetUpInfo.SendTime.Value.Date.ShouldBe(DateTime.Now.Date));
        }
        protected override void SetPageSessionContext()
        {
            base.SetPageSessionContext();
            _responseOptionsPropertyWrapper     = string.Empty;
            _questionDeleteMethodCallCount      = 0;
            _itemCommandRegisteredStartupScript = false;
            _defineQuestionsInstance            = new DefineQuestions();
            _shimDefineQuestions          = new ShimDefineQuestions(_defineQuestionsInstance);
            _defineQuestionsPrivateObject = new PrivateObject(_defineQuestionsInstance);
            InitializeAllControls(_defineQuestionsInstance);
            _shimDefineQuestions.ResponseoptionsGet       = () => _responseOptionsPropertyWrapper;
            _shimDefineQuestions.ResponseoptionsSetString = (responseOptions) => _responseOptionsPropertyWrapper = responseOptions;
            ShimQuestion.DeleteInt32User = (i, u) => _questionDeleteMethodCallCount++;
            SetPageControls();
            var shimEcnSession = new ShimECNSession();

            ShimECNSession.CurrentSession = () => shimEcnSession;
            ECNSession.CurrentSession().CurrentUser = new KMPlatform.Entity.User()
            {
                UserID = 10
            };
        }