public void VerifyForeignKeysExist_NotChampionLayoutExistContentSlot9Exists_ReturnString() { // Arrange var blastId = 1; var blastGroupId = 1; var blastEngine = new ECNBlastEngine(); var exceptionMsg = "ContentExist"; ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) => { var blast = new BlastRegular(); blast.BlastID = blastId; blast.GroupID = blastGroupId; blast.BlastType = BlastType.HTML.ToString(); blast.LayoutID = 1; return(blast); }; ShimGroup.GetByGroupID_NoAccessCheckInt32 = (id) => { var group = new Group(); return(group); }; ShimDataFunctions.GetDataTableSqlCommand = (cmd) => { return(new DataTable()); }; ShimLayout.GetByLayoutID_NoAccessCheckInt32Boolean = (id, child) => { var layout = new Layout(); layout.ContentSlot1 = 0; layout.ContentSlot9 = 1; return(layout); }; ShimECNBlastEngine.AllInstances.ContentExistsInt32 = (eng, id) => { if (id == 1) { return("ContentExist"); } return(""); }; // Act var actualResult = typeof(ECNBlastEngine).CallMethod(METHOD_VerifyForeignKey, new object[] { blastId }, blastEngine).ToString(); // Assert StringAssert.Contains(actualResult, exceptionMsg); }
public void VerifyForeignKeysExist_IsChampionSampleIDExistLayoutExistWithException_ReturnString() { // Arrange var blastId = 1; var blastGroupId = 1; var blastEngine = new ECNBlastEngine(); var exceptionMsg = "UDF(s): "; ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) => { var blast = new BlastRegular(); blast.BlastID = blastId; blast.GroupID = blastGroupId; blast.BlastType = BlastType.Champion.ToString(); blast.LayoutID = 1; blast.SampleID = 1; return(blast); }; ShimGroup.GetByGroupID_NoAccessCheckInt32 = (id) => { var group = new Group(); return(group); }; ShimDataFunctions.GetDataTableSqlCommand = (cmd) => { var table = new DataTable(); table.Columns.Add("LayoutID", typeof(string)); var row = table.NewRow(); row[0] = "1"; table.Rows.Add(row); var row2 = table.NewRow(); row2[0] = "1"; table.Rows.Add(row2); return(table); }; ShimLayout.GetByLayoutID_NoAccessCheckInt32Boolean = (id, child) => { var layout = new Layout(); layout.ContentSlot1 = 0; layout.TemplateID = 1; return(layout); }; ShimECNBlastEngine.AllInstances.ContentExistsInt32 = (eng, id) => { return("ContentExist"); }; ShimTemplate.GetByTemplateID_NoAccessCheckInt32 = (id) => { var template = new Template { TemplateSource = "TemplateSource", TemplateText = "TemplateText" }; return(template); }; ShimGroup.ValidateDynamicStringsForTemplateListOfStringInt32User = (list, groupId, user) => { throw new ECNException(new List <ECNError>() { new ECNError { ErrorMessage = "Exception from Template subject line. error text", } }); }; // Act var actualResult = typeof(ECNBlastEngine).CallMethod(METHOD_VerifyForeignKey, new object[] { blastId }, blastEngine).ToString(); // Assert StringAssert.Contains(actualResult, exceptionMsg); }
public void VerifyForeignKeysExist_IsChampionBlastIsNull_ReturnString() { // Arrange var blastId = 1; var blastGroupId = 1; var blastEngine = new ECNBlastEngine(); var exceptionMsg = "Blast ID:"; var firsTimeCall = true; ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) => { if (firsTimeCall) { var blast = new BlastRegular(); blast.BlastID = blastId; blast.GroupID = blastGroupId; blast.BlastType = BlastType.Champion.ToString(); blast.LayoutID = 1; firsTimeCall = false; return(blast); } else { return(null); } }; ShimGroup.GetByGroupID_NoAccessCheckInt32 = (id) => { var group = new Group(); return(group); }; ShimDataFunctions.GetDataTableSqlCommand = (cmd) => { return(new DataTable()); }; ShimLayout.GetByLayoutID_NoAccessCheckInt32Boolean = (id, child) => { var layout = new Layout(); layout.ContentSlot1 = 0; layout.TemplateID = 1; return(layout); }; ShimECNBlastEngine.AllInstances.ContentExistsInt32 = (eng, id) => { return("ContentExist"); }; ShimTemplate.GetByTemplateID_NoAccessCheckInt32 = (id) => { var template = new Template { TemplateSource = "TemplateSource", TemplateText = "TemplateText" }; return(template); }; ShimGroup.ValidateDynamicStringsForTemplateListOfStringInt32User = (list, groupId, user) => { }; // Act var actualResult = typeof(ECNBlastEngine).CallMethod(METHOD_VerifyForeignKey, new object[] { blastId }, blastEngine).ToString(); // Assert StringAssert.Contains(actualResult, exceptionMsg); }
public void HandleSingleBlast_RefBlastNotNullOpensCountIsZero_ReachEnd() { // Arrange var emailFn = new EmailFunctions(); var blastEngine = new ECNBlastEngine(); var exceptionLogged = false; var blastId = 1; var blastGroupId = 1; appSettings.Add("LogStatistics", bool.TrueString); appSettings.Add("Communicator_VirtualPath", "TestString"); var blast = new BlastRegular(); blast.BlastID = blastId; blast.GroupID = blastGroupId; blast.BlastType = BlastType.HTML.ToString(); blast.CustomerID = 1; var reachedEnd = false; ShimApplicationLog.LogCriticalErrorExceptionStringInt32StringInt32Int32 = (ex, sourceMethod, applicationID, note, gdCharityID, ecnCustomerID) => { return(1); }; CommonFakes::ShimFileFunctions.LogActivityBooleanStringString = (output, activity, suffix) => { }; ShimDataFunctions.GetDataTableString = (cmd) => { var table = new DataTable(); table.Columns.Add("EmailID", typeof(int)); table.Columns.Add("BlastID", typeof(int)); table.Columns.Add("LayoutPlanID", typeof(int)); table.Columns.Add("BlastSingleID", typeof(int)); table.Columns.Add("GroupID", typeof(int)); table.Columns.Add("refBlastID", typeof(int)); var row = table.NewRow(); row[0] = 1; row[1] = 2; row[2] = 3; row[3] = 4; row[4] = 5; row[5] = 6; table.Rows.Add(row); return(table); }; ShimECNBlastEngine.AllInstances.SetBlastSingleToErrorInt32 = (eng, id) => { }; ShimDataFunctions.ExecuteString = (str) => { return(1); }; ShimDataFunctions.ExecuteScalarString = (str) => { if (str.Contains("SELECT COUNT(EmailID) AS 'OpensCount'")) { if (str.Contains("AND ActionTypeCode = 'open'")) { reachedEnd = true; } return("0"); } return("1"); }; ShimDataFunctions.ExecuteScalarStringString = (str, cmd) => { return("1"); }; ShimBlast.GetByBlastID_NoAccessCheckInt32Boolean = (id, child) => { return(blast); }; ShimChannelCheck.AllInstances.getHostName = (ch) => "TestHostName"; ShimChannelCheck.AllInstances.getBounceDomain = (ch) => "TestDomain"; ShimChannelCheck.ConstructorInt32 = (chn, custId) => { }; ShimBlast.GetMasterRefBlastInt32Int32UserBoolean = (id, emailId, user, child) => { return(blast); }; ShimEmailFunctions.AllInstances.SendBlastSingleBlastInt32Int32StringStringString = (fn, obj, email, group, setting, hostname, domain) => { }; // Act typeof(ECNBlastEngine).CallMethod(METHOD_HandleSingleBlast, new object[] { emailFn }, blastEngine); // Assert Assert.IsFalse(exceptionLogged); Assert.IsTrue(reachedEnd); }