예제 #1
0
        public void SetUp(IList <string> fileNames)
        {
            client   = TestClient.CreateNaked(session);
            supplier = TestSupplier.CreateNaked(session);

            var from = String.Format("{0}@test.test", client.Id);

            PrepareSupplier(supplier, from);

            byte[] bytes;
            if (IsEmlFile)
            {
                bytes = File.ReadAllBytes(fileNames[0]);
            }
            else
            {
                var message = ImapHelper.BuildMessageWithAttachments(
                    String.Format("{0}@waybills.analit.net", client.Addresses[0].Id),
                    from, fileNames.ToArray());
                bytes = message.ToByteData();
            }

            ImapHelper.StoreMessage(
                Settings.Default.TestIMAPUser,
                Settings.Default.TestIMAPPass,
                Settings.Default.IMAPSourceFolder, bytes);
        }
예제 #2
0
        public void Ignore_document_for_wrong_address()
        {
            var begin    = DateTime.Now;
            var supplier = TestSupplier.CreateNaked(session);
            var from     = String.Format("{0}@test.test", supplier.Id);

            PrepareSupplier(supplier, from);

            var message = ImapHelper.BuildMessageWithAttachments(
                String.Format("{0}@waybills.analit.net", "1"),
                from,
                new[] { @"..\..\Data\Waybills\bi055540.DBF" });
            var bytes = message.ToByteData();

            ImapHelper.StoreMessage(
                Settings.Default.TestIMAPUser,
                Settings.Default.TestIMAPPass,
                Settings.Default.IMAPSourceFolder, bytes);
            this.supplier = supplier;

            Process();
            var docs = session.Query <TestDocumentLog>().Where(d => d.LogTime > begin).ToList();

            Assert.That(docs.Count, Is.EqualTo(0));
        }
        public void Resend_eml_price()
        {
            var file = "price1.zip";

            source.SourceType = PriceSourceType.Email;
            source.EmailFrom  = "*****@*****.**";
            source.EmailTo    = "*****@*****.**";
            source.PricePath  = file;
            source.ExtrMask   = "price.txt";
            source.Save();

            PriceDownloadLog downloadLog;

            using (var scope = new TransactionScope(OnDispose.Rollback)) {
                downloadLog = new PriceDownloadLog {
                    Addition     = String.Empty,
                    ArchFileName = file,
                    ExtrFileName = "price.txt",
                    Host         = Environment.MachineName,
                    LogTime      = DateTime.Now,
                    PriceItemId  = priceItem.Id,
                    ResultCode   = 2
                };
                downloadLog.Save();
                scope.VoteCommit();
            }

            using (var sw = new FileStream(Path.Combine(Settings.Default.HistoryPath, downloadLog.Id + ".eml"), FileMode.CreateNew)) {
                var attachments = new List <string> {
                    Path.Combine(DataDirectory, file)
                };
                var message = ImapHelper.BuildMessageWithAttachments("*****@*****.**", "*****@*****.**", attachments.ToArray());
                var bytes   = message.ToByteData();
                sw.Write(bytes, 0, bytes.Length);
            }
            WcfCallResendPrice(downloadLog.Id);

            Assert.That(PriceItemList.list.FirstOrDefault(i => i.PriceItemId == priceItem.Id), Is.Not.Null, "Прайса нет в очереди на формализацию");
            Assert.IsFalse(File.Exists(Path.Combine(Path.GetTempPath(), file)), "Не удален временный файл из темп");
        }
예제 #4
0
        public void MiniMailOnUnknownProvider()
        {
            var files = new List <string> {
                @"..\..\Data\Waybills\bi055540.DBF",
            };

            //SetUp без регистрации тестовой почты --begin--
            client   = TestClient.CreateNaked(session);
            supplier = TestSupplier.CreateNaked(session);

            var from = String.Format("{0}@test.test", client.Id);

            session.Save(supplier);

            byte[] bytes;
            if (IsEmlFile)
            {
                bytes = File.ReadAllBytes(files[0]);
            }
            else
            {
                var message = ImapHelper.BuildMessageWithAttachments(
                    String.Format("{0}@waybills.analit.net", client.Addresses[0].Id),
                    from, files.ToArray());
                bytes = message.ToByteData();
            }

            ImapHelper.StoreMessage(
                Settings.Default.TestIMAPUser,
                Settings.Default.TestIMAPPass,
                Settings.Default.IMAPSourceFolder, bytes);
            //--EndSetUp--

            Process();

            var logs = session.Query <RejectedEmail>().Where(log =>
                                                             log.From == from);

            Assert.That(logs.Count(), Is.Not.Null);
        }
        public void NotFoundSupplierError()
        {
            var supplier = TestSupplier.CreateNaked(session);
            var from     = String.Format("{0}@supplier.test", supplier.Id);

            var message = ImapHelper.BuildMessageWithAttachments(
                "test NotFoundSupplier",
                "body NotFoundSupplier",
                new string[] { "*****@*****.**" },
                new[] { from },
                null);

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

            try {
                handler.CheckMime(message);
                Assert.Fail("Должно было возникнуть исключение MiniMailOnUnknownProviderException");
            }
            catch (MiniMailOnUnknownProviderException exception) {
                Assert.That(exception.Template, Is.EqualTo(ResponseTemplate.MiniMailOnUnknownProvider));
                Assert.That(exception.SuppliersEmails, Is.StringContaining(from));
                SendErrorToProvider(handler, exception, message);
            }
        }