Esempio n. 1
0
        public void CertificateExists()
        {
            var rostaSource = new RostaCertificateSource();

            var product = Product.FindFirst();

            var line = new DocumentLine {
                Code          = "22651",
                SerialNumber  = "835495",
                ProductEntity = product
            };

            Assert.That(rostaSource.CertificateExists(line), Is.False);
            var catalog = new CertificateSourceCatalog {
                CertificateSource = _source,
                SerialNumber      = line.SerialNumber,
                //Код в накладной и в каталоге может не совпадать, сравниваем по CatalogId
                SupplierCode   = "C!" + line.Code,
                CatalogProduct = product.CatalogProduct,
                OriginFilePath = Path.GetRandomFileName()
            };

            catalog.Save();
            Assert.That(rostaSource.CertificateExists(line), Is.True);
        }
        public void DeleteTempFolderTest()
        {
            var rostaSource = new RostaCertificateSource();
            var product     = session.Query <Product>().First(p => p.CatalogProduct != null);
            var documentLog = new TestDocumentLog {
                Supplier     = _testSupplier,
                Client       = _testUser.Client,
                DocumentType = DocumentType.Waybill,
                LogTime      = DateTime.Now,
                FileName     = Path.GetRandomFileName() + ".txt"
            };
            var document = new TestWaybill(documentLog);

            session.Save(document);

            var realDocument = session.Load <Document>(document.Id);

            var task = new CertificateTask {
                SerialNumber   = "123",
                CatalogProduct = product.CatalogProduct,
            };

            task.CertificateSource = _source;
            task.DocumentLine      = new DocumentLine {
                Code          = "000002",
                SerialNumber  = "C392764",
                Document      = realDocument,
                ProductEntity = product
            };
            Save(task.DocumentLine);
            Save(task);

            var certificsteCatalog = new CertificateSourceCatalog {
                CertificateSource = _source,
                SerialNumber      = task.DocumentLine.SerialNumber,
                SupplierCode      = task.DocumentLine.Code,
                OriginFilePath    = "005/0052602p-0.gif",
                CatalogProduct    = product.CatalogProduct
            };

            Save(certificsteCatalog);
            Reopen();
            rostaSource.GetCertificateFiles(task, session);
            // Проверяем, что временная папка удалена
            Assert.That(Directory.Exists(rostaSource.TMPDownloadDir), Is.False);
        }
Esempio n. 3
0
        public void TestGetFiles()
        {
            var rostaSource = new RostaCertificateSource();
            var task        = new CertificateTask();

            task.CertificateSource = _source;
            task.DocumentLine      = new DocumentLine {
                Code         = "000002",
                SerialNumber = "C392764"
            };

            var catalog = new CertificateSourceCatalog {
                CertificateSource = _source,
                SerialNumber      = task.DocumentLine.SerialNumber,
                SupplierCode      = task.DocumentLine.Code,
                OriginFilePath    = "005/0052602p-0.gif"
            };

            catalog.Save();

            catalog = new CertificateSourceCatalog {
                CertificateSource = _source,
                SerialNumber      = task.DocumentLine.SerialNumber,
                SupplierCode      = task.DocumentLine.Code,
                OriginFilePath    = "005/0052602pd-0.gif"
            };
            catalog.Save();

            var files = rostaSource.GetCertificateFiles(task, session);

            Assert.That(files.Count, Is.EqualTo(2));
            var file = files[0];

            Assert.That(File.Exists(file.LocalFile), Is.True, "файл не существует {0}", file.LocalFile);
            Assert.That(file.ExternalFileId, Is.EqualTo(@"005/0052602p-0.gif"));
            Assert.That(file.OriginFilename, Is.EqualTo(@"0052602p-0.gif"));
            Assert.That(file.Extension, Is.EqualTo(".GIF").IgnoreCase);
        }