public void TestIfModelIsSavingEmail() { // Arrange EmailModel model = new EmailModel(new FakeUnitOfWork()); string receipts = "*****@*****.**"; string subject = "testing email save"; string body = "this is a test"; string username = "******"; int employeeId = 1; CS_Email savedEmail = null; // Act savedEmail = model.SaveEmail(receipts, subject, body, username, employeeId); // Assert Assert.IsNotNull(savedEmail); Assert.AreEqual("*****@*****.**", savedEmail.Receipts, "Error on Receipts field"); Assert.AreEqual(subject, savedEmail.Subject, "Error on Subject field"); Assert.AreEqual(body, savedEmail.Body, "Error on Body field"); Assert.AreEqual(username, savedEmail.CreatedBy, "Error on CreatedBy field"); Assert.AreEqual(employeeId, savedEmail.CreationID, "Error on CreationID field"); Assert.AreEqual((short)Globals.EmailService.Status.Pending, savedEmail.Status, "Error on Status Field"); }
/// <summary> /// Sends the request Customer email /// </summary> /// <param name="emailBody">Email body</param> /// <param name="resend">Indicates if it's a new attempt of sending the request (TRUE) or it's the first attempt (FALSE)</param> /// <param name="cancel">Indicates if it's a new attempt of cancelling the request (TRUE) or it's the first attempt (FALSE)</param> /// <param name="customerNumber">If it's an update request, this field will have the Master Customer ID, if not it will be null</param> /// <param name="username">Username that made the request</param> private void SendCustomerRequestEmail(string emailBody, bool resend, bool cancel, string customerNumber, string username) { string subject = "New Company Request"; if (resend) subject += " (RESEND)"; if (cancel) subject += " (CANCEL)"; if (!string.IsNullOrEmpty(customerNumber)) subject += " - Master ID: " + customerNumber; string[] receipts = null; SettingsModel settingsModel = new SettingsModel(_unitOfWork); string emails = settingsModel.GetCustomerRequestEmails(); if (!string.IsNullOrEmpty(emails)) receipts = emails.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (null != receipts) { EmailModel emailModel = new EmailModel(_unitOfWork); for (int i = 0; i < receipts.Length; i++) { emailModel.SaveEmail(receipts[i], subject, emailBody, username, null); } } }