public void Download_source()
        {
            var testProduct = new TestProduct("Тестовый продукт");

            session.Save(testProduct);
            var product = Product.Find(testProduct.Id);

            var source = new KatrenSource();

            var certificateSource = new CertificateSource();

            certificateSource.SourceClassName = source.GetType().Name;
            session.Save(certificateSource);

            var line = new DocumentLine {
                ProductEntity = product,
                SerialNumber  = "012011",
            };

            var sourceCatalog = new CertificateSourceCatalog {
                CertificateSource    = certificateSource,
                SerialNumber         = line.SerialNumber,
                CatalogProduct       = product.CatalogProduct,
                SupplierCode         = "34266440",
                SupplierProducerCode = "13483667",
                OriginFilePath       = KatrenSource.ToOriginFileName(0x1B9EFC8),
            };

            session.Save(sourceCatalog);

            var task  = new CertificateTask(certificateSource, line);
            var files = source.GetCertificateFiles(task, null);

            Assert.That(files.Count, Is.EqualTo(4));
        }
        public void Load_file_without_dir()
        {
            FTP_Server server = null;

            try {
                server = new FTP_Server();
                var port = new Random().Next(10000, 20000);
                server.BindInfo = new[] { new BindInfo(BindInfoProtocol.TCP, IPAddress.Loopback, port), };
                server.StartServer();
                var testProduct = new TestProduct("Тестовый продукт");
                session.Save(testProduct);
                var product = session.Load <Product>(testProduct.Id);
                var line    = new DocumentLine {
                    ProductEntity = product,
                    SerialNumber  = "012011",
                };

                var source            = new KatrenSource();
                var certificateSource = new CertificateSource();
                certificateSource.SourceClassName = source.GetType().Name;
                session.Save(certificateSource);

                var sourceCatalog = new CertificateSourceCatalog {
                    CertificateSource    = certificateSource,
                    SerialNumber         = line.SerialNumber,
                    CatalogProduct       = product.CatalogProduct,
                    SupplierCode         = "34266440",
                    SupplierProducerCode = "13483667",
                    OriginFilePath       = KatrenSource.ToOriginFileName(0x1B9EFC8),
                };
                session.Save(sourceCatalog);
                certificateSource.LookupUrl = String.Format("ftp://127.0.0.1:{0}/", port);

                source.GetFilesFromSource(new CertificateTask(certificateSource, line), new List <CertificateFile>());
            }
            finally {
                if (server != null)
                {
                    server.Dispose();
                }
            }
        }