コード例 #1
0
        public void CloneBlast_OnException_LogError()
        {
            // Arrange
            var exceptionLogged = false;
            var blastEngine     = new ECNBlastEngine();
            var blastId         = 1;
            var blastGroupId    = 1;
            var blast           = new EntitiesCommunicator::BlastRegular();

            blast.BlastID       = blastId;
            blast.GroupID       = blastGroupId;
            blast.BlastType     = BlastType.HTML.ToString();
            blast.CustomerID    = 1;
            blast.CreatedUserID = 1;
            var setupInfo = new EntitiesCommunicator::BlastSetupInfo();

            CommonFakes::ShimFileFunctions.LogConsoleActivityStringString = (str, output) => { };
            ShimDataFunctions.GetDataTableString = (cmd) =>
            {
                throw new Exception("Exception from SqlCommand");
            };
            ShimECNBlastEngine.AllInstances.SetBlastSingleToErrorInt32 = (eng, id) => { };
            ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean           = (id, child) =>
            {
                return(blast);
            };
            BusinessLogicFakes::ShimUser.GetByUserIDInt32Boolean = (id, child) =>
            {
                return(new User
                {
                    UserID = 1
                });
            };
            AccountsFakes::ShimCustomer.GetByCustomerIDInt32Boolean = (id, child) =>
            {
                throw new CommonObjects::SecurityException("SecurityExceptionMessage");
            };
            ShimECNBlastEngine.AllInstances.SendAccountManagersEmailNotificationStringString = (eng, msg, exc) =>
            {
                exceptionLogged = true;
            };

            // Act
            typeof(ECNBlastEngine).CallMethod(METHOD_CloneBlast,
                                              new object[]
            {
                blastId,
                setupInfo
            }, blastEngine);

            // Assert
            Assert.IsTrue(exceptionLogged);
        }
コード例 #2
0
        public void CloneBlast_CampaignItemExist_ReachEnd()
        {
            // Arrange
            var exceptionLogged = false;
            var reachedEnd      = false;
            var blastEngine     = new ECNBlastEngine();
            var blastId         = 1;
            var blastGroupId    = 1;

            appSettings.Add("LogStatistics", bool.TrueString);
            var blast = new EntitiesCommunicator::BlastRegular();

            blast.BlastID       = blastId;
            blast.GroupID       = blastGroupId;
            blast.BlastType     = BlastType.HTML.ToString();
            blast.CustomerID    = 1;
            blast.CreatedUserID = 1;
            var setupInfo = new EntitiesCommunicator::BlastSetupInfo();

            CommonFakes::ShimFileFunctions.LogConsoleActivityStringString = (str, output) => { };
            ShimDataFunctions.GetDataTableString = (cmd) =>
            {
                throw new Exception("Exception from SqlCommand");
            };
            ShimECNBlastEngine.AllInstances.SetBlastSingleToErrorInt32 = (eng, id) => { };
            ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean           = (id, child) =>
            {
                return(blast);
            };
            BusinessLogicFakes::ShimUser.GetByUserIDInt32Boolean = (id, child) =>
            {
                return(new User
                {
                    UserID = 1
                });
            };
            AccountsFakes::ShimCustomer.GetByCustomerIDInt32Boolean = (id, child) =>
            {
                return(new AccountsEntity::Customer
                {
                    BaseChannelID = 1,
                    PlatformClientID = 1
                });
            };
            BusinessLayerAccountsFakes::ShimBaseChannel.GetByBaseChannelIDInt32 = (id) =>
            {
                return(new AccountsEntity::BaseChannel
                {
                    PlatformClientGroupID = 1
                });
            };
            ShimECNBlastEngine.AllInstances.SendAccountManagersEmailNotificationStringString = (eng, msg, exc) =>
            {
                exceptionLogged = true;
            };
            BusinessLogicFakes::ShimClient.AllInstances.SelectInt32Boolean = (obj, id, include) =>
            {
                return(new Client
                {
                    ClientID = 1
                });
            };
            BusinessLogicFakes::ShimClientGroup.AllInstances.SelectInt32Boolean = (obj, id, include) =>
            {
                return(new ClientGroup());
            };
            BusinessLogicFakes::ShimSecurityGroup.AllInstances.SelectInt32Int32BooleanBoolean =
                (obj, uid, cid, isKm, include) =>
            {
                return(new SecurityGroup());
            };
            ShimCampaignItem.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) =>
            {
                return(new EntitiesCommunicator::CampaignItem
                {
                    CampaignID = 1,
                    CampaignItemID = 1,
                    CampaignItemType = CampaignItemType.Regular.ToString(),
                    SendTime = new DateTime(2018, 1, 1),
                    CampaignItemName = "TestCampaignItemName",
                    CampaignItemIDOriginal = 1,
                    CampaignItemNameOriginal = "TestCampaignItemNameOriginal",
                    BlastList = new List <EntitiesCommunicator::CampaignItemBlast>
                    {
                        new EntitiesCommunicator::CampaignItemBlast
                        {
                            BlastID = blastId
                        }
                    },
                    SuppressionList = new List <EntitiesCommunicator::CampaignItemSuppression>()
                });
            };
            ShimCampaignItem.Save_NoAccessCheckCampaignItemUser                  = (item, user) => 1;
            ShimCampaignItemBlast.Save_NoAccessCheckCampaignItemBlastUser        = (item, user) => 1;
            ShimBlast.CreateBlastsFromCampaignItem_NoAccessCheckInt32UserBoolean = (id, user, child) => { };
            ShimBlast.GetByCampaignItemBlastID_NoAccessCheckInt32Boolean         = (id, child) =>
            {
                reachedEnd = true;
                return(null);
            };

            // Act
            typeof(ECNBlastEngine).CallMethod(METHOD_CloneBlast,
                                              new object[]
            {
                blastId,
                setupInfo
            }, blastEngine);

            // Assert
            Assert.IsFalse(exceptionLogged);
            Assert.IsTrue(reachedEnd);
        }