Exemplo n.º 1
0
 private void Process()
 {
     session.Transaction.Commit();
     handler = new WaybillEmailSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass);
     handler.CreateDirectoryPath();
     handler.ProcessData();
 }
Exemplo n.º 2
0
        public void Check_destination_addresses()
        {
            client = TestClient.CreateNaked(session);
            session.Transaction.Commit();

            handler = new WaybillEmailSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass);

            var message = Mime.Parse(@"..\..\Data\EmailSourceHandlerTest\WithCC.eml");

            message.MainEntity.To.Clear();
            message.MainEntity.Cc.Clear();

            var addrTo = new GroupAddress();

            addrTo.GroupMembers.Add(new MailboxAddress("*****@*****.**"));
            message.MainEntity.To.Add(addrTo);

            var addrCc = new GroupAddress();

            addrCc.GroupMembers.Add(new MailboxAddress(String.Format("{0}@waybills.analit.net", client.Addresses[0].Id)));
            addrCc.GroupMembers.Add(new MailboxAddress("*****@*****.**"));
            message.MainEntity.Cc.Add(addrCc);

            handler.CheckMime(message);
        }
Exemplo n.º 3
0
        public void Reject_message_for_client_with_another_region()
        {
            client   = TestClient.CreateNaked(session, 2, 2);
            supplier = TestSupplier.CreateNaked(session);
            supplier.WaybillSource.SourceType = TestWaybillSourceType.Email;
            supplier.WaybillSource.EMailFrom  = String.Format("{0}@sup.com", supplier.Id);
            session.Save(supplier);

            handler = new WaybillEmailSourceHandlerForTesting("", "");
            handler.CreateDirectoryPath();

            var mime = new Mime();

            mime.MainEntity.Subject = "Тестовое сообщение";
            mime.MainEntity.To      = new AddressList {
                new MailboxAddress(String.Format("{0}@waybills.analit.net", client.Addresses[0].Id))
            };
            mime.MainEntity.From = new AddressList {
                new MailboxAddress(String.Format("{0}@sup.com", supplier.Id))
            };
            mime.MainEntity.ContentType = MediaType_enum.Multipart_mixed;
            mime.MainEntity.ChildEntities.Add(new MimeEntity {
                ContentDisposition          = ContentDisposition_enum.Attachment,
                ContentType                 = MediaType_enum.Text_plain,
                ContentTransferEncoding     = ContentTransferEncoding_enum.Base64,
                ContentDisposition_FileName = "text.txt",
                Data = Enumerable.Repeat(100, 100).Select(i => (byte)i).ToArray()
            });
            session.Transaction.Commit();
            handler.ProcessMime(mime);

            Assert.That(handler.Sended.Count, Is.EqualTo(1));
            var message = handler.Sended[0];

            Assert.That(message.MainEntity.Subject, Is.EqualTo("Ваше Сообщение не доставлено одной или нескольким аптекам"));
            Assert.That(message.MainEntity.ChildEntities[0].DataText, Is.StringContaining("с темой: \"Тестовое сообщение\" не были доставлены аптеке, т.к. указанный адрес получателя"));
        }