Beispiel #1
0
        public void VerifyEmailContent(long ConfirmationId, DateTime pickupDate, bool isCanada = false, bool hasLTLIns = false, bool isFTL = false, string truckType = "")
        {
            // var initialEmailCount = 0;
            string userEmail = ConfigurationManager.AppSettings["UserName"];
            var    email     = (from eml in DataContext.email_history_load join ehist in DataContext.email_history on eml.email_history_id equals ehist.email_history_id where eml.load_id == ConfirmationId && ehist.send_to == userEmail orderby ehist.send_time descending select new { LoadID = eml.load_id, Email_Id = eml.email_history_id, Sent_To = ehist.send_to, Subject = ehist.subject, Email_Content = ehist.text, Send_Time = ehist.send_time }).ToList();
            //initialEmailCount = email.Count;
            int count       = 0;
            int waitTimeSec = 60;

            if (email.Count <= 0)
            {
                while (email.Count == 0 && count < waitTimeSec)
                {
                    Driver.Sleep();
                    count++;
                    email = (from eml in DataContext.email_history_load join ehist in DataContext.email_history on eml.email_history_id equals ehist.email_history_id where eml.load_id == ConfirmationId && ehist.send_to == userEmail orderby ehist.send_time descending select new { LoadID = eml.load_id, Email_Id = eml.email_history_id, Sent_To = ehist.send_to, Subject = ehist.subject, Email_Content = ehist.text, Send_Time = ehist.send_time }).ToList();
                }
            }

            if (email.Count <= 0)
            {
                Assert.Fail("Email sent to " + ConfigurationManager.AppSettings["UserName"] + " could not be found for load " + ConfirmationId + " after waiting for " + count + " seconds");
            }
            else
            {
                var emailContent = email[0].Email_Content;
                Assert.Pass("Email content retrieved for load " + ConfirmationId + ", email sent to " + ConfigurationManager.AppSettings["UserName"]);
                Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, ConfirmationId.ToString()), "Check if confirmation email has confirmation number - Expecting " + ConfirmationId.ToString());
                Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.strPckAddressLine1.ToString()), "Check if confirmation email has the following pick up address for load " + ConfirmationId + " - Expecting " + InputData.Data.strPckAddressLine1.ToString());
                Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.strDelAddressLine1.ToString()), "Check if confirmation email has the following delivery address for load " + ConfirmationId + " - Expecting " + InputData.Data.strDelAddressLine1.ToString());
                Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.strCityDestination.ToString()), "Check if confirmation email has delivery city state zip for load " + ConfirmationId + " - Expecting " + InputData.Data.strFullCityDestination.ToString());
                if (isFTL == true)
                {
                    Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.strCitySource.ToString()), "Check if confirmation email has pickup city state zip for load " + ConfirmationId + " - Expecting " + InputData.Data.strFullCitySource.ToString());
                    var quote = GetGlobalFinalQuoteVarByTruckType(truckType);
                    Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, "$" + String.Format("{0:0.00}", quote)), "Check if confirmation email has the final quote price for load " + ConfirmationId + " - Expecting " + "$" + String.Format("{0:0.00}", quote));
                }
                else
                {
                    if (isCanada == false)
                    {
                        Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.strCitySource.ToString()), "Check if confirmation email has pickup city state zip for load " + ConfirmationId + " - Expecting " + InputData.Data.strFullCitySource.ToString());
                        Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, "$" + String.Format("{0:0.00}", InputData.Data.FinalQuote)), "Check if confirmation email has the final quote price for load " + ConfirmationId + " - Expecting " + "$" + String.Format("{0:0.00}", InputData.Data.FinalQuote));
                        Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.CarrierName.ToString()), "Check if confirmation email has carrier name for load " + ConfirmationId + " - Expecting " + InputData.Data.CarrierName.ToString());
                    }
                    else
                    {
                        Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.strCitySourceCAN.ToString()), "Check if confirmation email has Canadian pickup city state zip for load " + ConfirmationId + " - Expecting " + InputData.Data.strFullCitySourceCAN.ToString());
                        var finalQuote = GetGlobalFinalQuoteVarByIns(hasLTLIns);
                        Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, "$" + String.Format("{0:0.00}", finalQuote)), "Check if confirmation email has the final quote price for load " + ConfirmationId + " - Expecting " + "$" + String.Format("{0:0.00}", finalQuote));
                        Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.CarrierNameCAN.ToString()), "Check if confirmation email has carrier name for load " + ConfirmationId + " - Expecting " + InputData.Data.CarrierNameCAN.ToString());
                    }
                    Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.strFrmPckPhoneNo.ToString()), "Check if confirmation email has pickup phone number for load " + ConfirmationId + " - Expecting " + InputData.Data.strFrmPckPhoneNo.ToString());
                    Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, InputData.Data.strFrmDelPhoneNo.ToString()), "Check if confirmation email has delivery phone number for load " + ConfirmationId + " - Expecting " + InputData.Data.strFrmDelPhoneNo.ToString());
                    Assert.IsTrue(Util.ContainsStrCaseInsensitive(emailContent, pickupDate.ToString("ddd MM/dd/yyyy")), "Check if confirmation email has the pickup date for load " + ConfirmationId + " - Expecting " + pickupDate.ToString("ddd MM/dd/yyyy"));
                }
            }
        }