コード例 #1
0
        public void Setup()
        {
            messages = new List <MailMessage>();
            ForTest.InitializeMailer();
            var mailer = ForTest.TestMailer(m => messages.Add(m));

            task = new SendInvoiceTask(mailer);
        }
コード例 #2
0
        public void Send_notification_aboutPremoderation()
        {
            var startCount = 5;
            var supplier   = CreateSupplier();
            var catalog    = FindFirstFreeCatalog();

            for (int i = 0; i < startCount; i++)
            {
                CreatePromotion(supplier, catalog, true);
            }
            for (int i = 0; i < startCount; i++)
            {
                CreatePromotion(supplier, catalog, false);
            }
            Flush();

            var promotions = session.Query <SupplierPromotion>()
                             .Where(p => !p.Moderated && p.Enabled).ToList();

            var timeToSendMail = ConfigurationManager.AppSettings["SendPremoderatedPomotionListAt"]
                                 .Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
            var timeToSendMailHour    = int.Parse(timeToSendMail[0]);
            var timeToSendMailMinutes = timeToSendMail.Length > 1 ? int.Parse(timeToSendMail[1]) : 0;
            var mailTime = SystemTime.Now().Date.AddHours(timeToSendMailHour).AddMinutes(timeToSendMailMinutes);

            SystemTime.Now = () => mailTime.AddMinutes(10);
            FlushAndCommit();
            var mailer = ForTest.TestMailer(m => messages.Add(m));

            task = new SendPremoderatedPomotionList(mailer);
            task.Execute();

            var messageExists = messages.Any(m => m.Body.Contains(String.Format("Ожидают модерации {0} промо-акций:", startCount)));

            Assert.That(messageExists);
            messages.Clear();
            promotions.Each(s => { s.Moderated = true; s.UpdateStatus(); session.Update(s); });
            promotions[0].Moderated = false;
            promotions[0].UpdateStatus();
            session.Update(promotions[0]);
            Flush();

            task.Execute();
            messageExists = messages.Any(m => m.Body.Contains(String.Format("Ожидают модерации {0} промо-акций:", 1)));
            Assert.That(messageExists);
        }
コード例 #3
0
        public void DeleteNewsNotifyTest()
        {
            var mailer = ForTest.TestMailer(m => message = m);

            mailer.RegisterOrDeleteNews(news, "Скрыта новость").Send();
            Assert.That(message, Is.Not.Null);
            Assert.That(message.Body, Is.StringEnding(String.Format(@"Дата изменения: {1}<br>
Сотрудник: test<br>
Хост: localhost<br>
Код новости: {0}<br>
Новость: <a href=""https://stat.analit.net/adm/News/{0}"">TestNewHeader</a><br>

Скрыта новость: <br/>
Тема: {3}</br>
Адресат: {2}</br>
Текст: {4}</br>", news.Id, DateTime.Now, news.DestinationType.GetDescription(), news.Header, news.Body)));
            Assert.That(message.To[0].ToString(), Is.EqualTo("*****@*****.**"));
            Assert.That(message.Subject, Is.EqualTo("Скрыта новость"));
        }
コード例 #4
0
        public void NotifyAboutEditAct()
        {
            MailMessage message = null;
            var         mailer  = ForTest.TestMailer(m => message = m);

            mailer.DbSession = session;

            var act = PrepareAct();

            mailer.ActModified(act);
            mailer.Send();
            Assert.That(message, Is.Not.Null);
            Assert.That(message.Body, Is.StringStarting(String.Format(@"{0}: <br/>
Документ №{1}, дата: {2}<br/>
Период: {5}<br/>
Сумма: {6}<br/>
Организация: {3}<br/>
Контрагент от Аналит: {4}<br/>
Пользователь: test<br/>
Дата и время изменения:", "Изменен акт", act.Id, act.Date.ToString("dd.MM.yyyy"),
                                                                      act.Customer, act.Recipient.Name, new Period(2012, Interval.January), 100)));
        }
コード例 #5
0
        public void Setup()
        {
            message    = null;
            controller = new RegisterController();

            PrepareController(controller, "Registered");
            ((StubRequest)Request).Uri             = new Uri("https://stat.analit.net/adm/Register/Register");
            ((StubRequest)Request).ApplicationPath = "/Adm";

            ForTest.InitializeMailer();
            mailer = ForTest.TestMailer(m => message = m);

            payer = new Payer("Тестовый плательщик")
            {
                Id = 10, JuridicalName = "FullTestPayerName"
            };
            client = new Client(payer, Data.DefaultRegion)
            {
                Id         = 58,
                Name       = "Тестовый клиент",
                HomeRegion = new Region {
                    Name = "test"
                },
                Settings = new DrugstoreSettings()
            };
            supplier = new Supplier {
                Name       = "Тестовый поставщик",
                HomeRegion = new Region {
                    Name = "testSupplierRegion"
                }
            };
            payer.Clients.Add(client);
            payer.Suppliers.Add(supplier);
            user = new User(payer, client);
            client.Users.Add(user);
        }
コード例 #6
0
 public void Setup()
 {
     ForTest.InitializeMailer();
     mailer  = ForTest.TestMailer(m => { });
     _client = DataMother.CreateTestClientWithUser();
 }