public void CheckRegionMask() { var regions = TestRegion.FindAll().ToList(); var vrnRegion = regions.Find(r => r.ShortAliase == "vrn"); var orelRegion = regions.Find(r => r.ShortAliase == "orel"); var client = TestClient.CreateNaked(vrnRegion.Id, vrnRegion.Id); var user = client.Users[0]; Assert.That(user.WorkRegionMask, Is.EqualTo(vrnRegion.Id), "У пользователя должен быть доступен только регион {0}", vrnRegion.Name); //к пользователю добаляем еще один регион в маску user.WorkRegionMask = user.WorkRegionMask | orelRegion.Id; var foundCause = String.Format("Пользователь {0} должен быть найден, т.к. маска клиента содержит регион {1} ({2})", user.Id, vrnRegion.Name, vrnRegion.Id); var notFoundCause = String.Format("Пользователь {0} не должен быть найден, т.к. маска клиента не должна содержать регион {1} ({2})", user.Id, orelRegion.Name, orelRegion.Id); CheckRegionMaskByRecipient(orelRegion.ShortAliase + "@docs.analit.net", RecipientType.Region, orelRegion, user, Is.Null, notFoundCause); CheckRegionMaskByRecipient(vrnRegion.ShortAliase + "@docs.analit.net", RecipientType.Region, vrnRegion, user, Is.Not.Null, foundCause); var address = client.Addresses[0]; CheckRegionMaskByRecipient(address.Id + "@docs.analit.net", RecipientType.Address, vrnRegion, user, Is.Not.Null, foundCause); CheckRegionMaskByRecipient(address.Id + "@docs.analit.net", RecipientType.Address, orelRegion, user, Is.Null, notFoundCause); CheckRegionMaskByRecipient(client.Id + "@client.docs.analit.net", RecipientType.Client, vrnRegion, user, Is.Not.Null, foundCause); CheckRegionMaskByRecipient(client.Id + "@client.docs.analit.net", RecipientType.Client, orelRegion, user, Is.Null, notFoundCause); }
public void LipetskFormaciaProtekExport() { var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var settings = session.Load <WaybillSettings>(client.Id); settings.AssortimentPriceId = supplier.Prices[0].Id; settings.WaybillConvertFormat = WaybillFormat.LipetskFarmacia; settings.IsConvertFormat = true; var path = @"..\..\Data\Waybills\446406_0.dbf"; var startLog = new DocumentReceiveLog(session.Load <Supplier>(supplier.Id), session.Load <Address>(client.Addresses[0].Id)) { DocumentType = DocType.Waybill, LogTime = DateTime.Now, }; session.Save(startLog); var document = WaybillParser.Parse(path, startLog); document.Log = startLog; document.DocumentDate = DateTime.Now; document.Log.IsFake = true; session.Save(document); //test Exporter.SaveProtek(document); var dblogs = session.Query <DocumentReceiveLog>().Where(i => i.ClientCode == client.Id).ToList(); Assert.That(dblogs.Count, Is.EqualTo(2)); Assert.That(dblogs[0].IsFake, Is.False); Assert.That(dblogs[1].IsFake, Is.False); }
public void Setup() { var supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); client = TestClient.CreateNaked(session); address = client.CreateAddress(); user = client.Users.First(); session.Save(address); ServiceContext.GetUserName = () => user.Login; var container = new WindsorContainer(); container.AddComponent("RepositoryInterceptor", typeof(RepositoryInterceptor)); container.AddComponent("OfferRepository", typeof(IOfferRepository), typeof(OfferRepository)); container.AddComponent("Repository", typeof(IRepository <>), typeof(Repository <>)); var holder = new SessionFactoryHolder(); holder .Configuration .AddInputStream(HbmSerializer.Default.Serialize(Assembly.Load("Common.Models"))); container.Kernel.AddComponentInstance <ISessionFactoryHolder>(holder); IoC.Initialize(container); IoC.Container.Register( Component.For <IInforoomOnlineService>() .ImplementedBy <InforoomOnlineService>() .Interceptors(InterceptorReference.ForType <ContextLoaderInterceptor>()) .Anywhere, Component.For <ContextLoaderInterceptor>(), Component.For <IClientLoader>().ImplementedBy <ClientLoader>()); service = IoC.Resolve <IInforoomOnlineService>(); }
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); }
public void LipetskFormaciaExporter() { var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var settings = session.Load <WaybillSettings>(client.Id); settings.AssortimentPriceId = supplier.Prices[0].Id; settings.WaybillConvertFormat = WaybillFormat.LipetskFarmacia; settings.IsConvertFormat = true; var path = @"..\..\Data\Waybills\446406_0.dbf"; var startLog = new DocumentReceiveLog(session.Load <Supplier>(supplier.Id), session.Load <Address>(client.Addresses[0].Id)) { DocumentType = DocType.Waybill, LogTime = DateTime.Now, }; session.Save(startLog); var document = WaybillParser.Parse(path, startLog); document.Log = startLog; document.DocumentDate = DateTime.Now; document.Log.IsFake = true; session.Save(document); //test var log = Exporter.ConvertAndSave(document, WaybillFormat.LipetskFarmacia, settings); Assert.That(log.FileName.Substring(log.FileName.Length - 4), Is.EqualTo(".xls")); Assert.That(document.Log.IsFake, Is.EqualTo(false)); }
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); }
public void Process_message_if_from_contains_more_than_one_address() { client = TestClient.CreateNaked(session); address = client.Addresses[0]; supplier = TestSupplier.CreateNaked(session); supplier.WaybillSource.EMailFrom = String.Format("edata{0}@msk.katren.ru", supplier.Id); supplier.WaybillSource.SourceType = TestWaybillSourceType.Email; session.Save(supplier); FileHelper.DeleteDir(Settings.Default.DocumentPath); ImapHelper.ClearImapFolder(); var mime = PatchTo(@"..\..\Data\Unparse.eml", String.Format("{0}@waybills.analit.net", address.Id), String.Format("edata{0}@msk.katren.ru,[email protected]", supplier.Id)); ImapHelper.StoreMessage(mime.ToByteData()); Process(); var files = GetFileForAddress(DocType.Waybill); Assert.That(files.Length, Is.EqualTo(1), "не обработали документ"); }
public void Configure_min_supplier_count() { var supplier1 = TestSupplier.CreateNaked(session); var supplier2 = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); Property("ReportType", 0); Property("CalculateByCatalog", false); Property("PriceCode", (int)supplier1.Prices[0].Id); Property("ReportIsFull", false); Property("MinSupplierCount", 2); Property("FirmCodeEqual", new List <ulong> { supplier1.Id, supplier2.Id }); // http://redmine.analit.net/issues/52707 Property("FirmCodeEqual2", new List <ulong> { supplier2.Id }); Property("Clients", new List <ulong> { client.Id }); BuildReport(reportType: typeof(SpecShortReport)); Assert.IsTrue(File.Exists("test.xls")); }
public void Check_max_supplier_count() { var supplier1 = TestSupplier.CreateNaked(session); var supplier2 = TestSupplier.CreateNaked(session); var supplier3 = TestSupplier.CreateNaked(session); var client1 = TestClient.CreateNaked(session); var client2 = TestClient.CreateNaked(session); client2.Users[0].CleanPrices(session, supplier3); session.CreateSQLQuery("update customers.intersection set AgencyEnabled = 0 where PriceId not in (:ids) and ClientId = :clientId") .SetParameter("clientId", client1.Id) .SetParameterList("ids", supplier1.Prices.Select(p => p.Id).ToArray()) .ExecuteUpdate(); Property("ReportType", 0); Property("CalculateByCatalog", false); Property("PriceCode", (int)supplier1.Prices[0].Id); Property("ReportIsFull", false); Property("FirmCodeEqual", new List <ulong> { supplier1.Id, supplier2.Id, supplier3.Id }); Property("Clients", new List <ulong> { client1.Id, client2.Id }); //проверяем отсутствие исключения Фактическое количество прайс листов меньше трех, получено прайс-листов 1 BuildReport(reportType: (typeof(SpecShortReport))); }
public void Check_max_supplier_count() { var supplier1 = TestSupplier.CreateNaked(session); var supplier2 = TestSupplier.CreateNaked(session); var supplier3 = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var client1 = TestClient.CreateNaked(session); session.CreateSQLQuery("update customers.intersection set AgencyEnabled = 0 where PriceId not in (:ids) and ClientId = :clientId") .SetParameter("clientId", client.Id) .SetParameterList("ids", supplier1.Prices.Select(p => p.Id).ToArray()) .ExecuteUpdate(); Property("PriceCode", supplier1.Prices[0].Id); Property("ProducerAccount", false); Property("AllAssortment", false); Property("WithWithoutProperties", false); Property("ShowCodeC", false); Property("ShowCodeCr", false); Property("FirmCodeEqual", new List <long> { supplier1.Id, supplier2.Id, supplier3.Id }); Property("Clients", new List <long> { client.Id, client1.Id }); //проверяем что не возникает ошибка //Для клиента ... получено фактическое количество прайс листов меньше трех, получено прайс-листов 1 ProcessReport(typeof(PricesOfCompetitorsReport)); }
public void Setup() { var client = TestClient.CreateNaked(session); var address = client.Addresses[0]; supplier = TestSupplier.CreateNaked(session); var waybill = new TestWaybill(new TestDocumentLog(supplier, address)); product1 = session.Query <TestProduct>().First(); product2 = session.Query <TestProduct>().Skip(1).First(); waybill.Lines.Add(new TestWaybillLine(waybill) { Product = "Аксетин", CatalogProduct = product1, Quantity = 10, SerialNumber = "4563", EAN13 = "5290931004832", ProducerCost = 56, SupplierCost = 100, }); waybill.Lines.Add(new TestWaybillLine(waybill) { Product = "Аксетин", CatalogProduct = product2, Quantity = 10, SerialNumber = "4563", EAN13 = "5290931004832", ProducerCost = 56, SupplierCost = 70, }); session.Save(waybill); }
public void Set_force_replication_after_formalization() { var client = TestClient.CreateNaked(); client.Settings.BuyingMatrix = session.Load <TestMatrix>(localPrice.Matrix.Id); session.CreateSQLQuery("insert into Usersettings.AnalitFReplicationInfo(UserId, FirmCode, ForceReplication) " + "select :userId, pd.FirmCode, 0 from Customers.Intersection i " + " join Usersettings.Pricesdata pd on pd.PriceCode = i.PriceId "+ "where i.ClientId = :clientId " + "group by i.ClientId, pd.FirmCode") .SetParameter("clientId", client.Id) .SetParameter("userId", client.Users[0].Id) .ExecuteUpdate(); FormalizeDefaultData(); var replications = session .CreateSQLQuery("select FirmCode, ForceReplication from Usersettings.AnalitFReplicationInfo where UserId = :userId") .SetParameter("userId", client.Users[0].Id) .List <object[]>(); Assert.That(replications.Count, Is.GreaterThan(0)); foreach (var replication in replications) { Assert.That(replication[1], Is.EqualTo(1), replication[0].ToString()); } }
public void FreeOrdersTest() { var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var product = new TestProduct("Тестовый продукт"); session.Save(product); var order = new TestOrder(client.Users.First(), supplier.Prices[0]); order.AddItem(product, 1, 100); session.Save(order); var result = ExecuteReport(); var sum1 = result.AsEnumerable().Where(r => r["OrdersSum"] != DBNull.Value).Sum(r => (decimal)r["OrdersSum"]); var freeOrdersQuery = session.CreateSQLQuery( String.Format("INSERT INTO billing.freeorders VALUES({0}, {1});", order.Address.Payer.Id, supplier.Payer.Id)); freeOrdersQuery.ExecuteUpdate(); result = ExecuteReport(); var sum2 = result.AsEnumerable().Where(r => r["OrdersSum"] != DBNull.Value).Sum(r => (decimal)r["OrdersSum"]); Assert.That(sum2, Is.EqualTo(sum1 - 100)); }
public void Show_junk() { supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); client = TestClient.CreateNaked(session); order = new TestOrder(client.Users[0], supplier.Prices[0]); order.WriteTime = order.WriteTime.AddDays(-1); var offer = supplier.Prices[0].Core[0]; offer.Junk = true; order.AddItem(offer, 10); session.Save(order); Property("ProductNamePosition", 0); Property("MnnPosition", 1); Property("ShowCode", true); Property("ByPreviousMonth", false); Property("ReportInterval", 1); Property("SourceFirmCode", (int)supplier.Id); Property("HideJunk", false); var sheet = ReadReport <MixedReport>(); var text = ToText(sheet); Assert.That(text, Does.Contain(offer.Code)); Assert.That(text, Is.Not.StringContaining("Из отчета исключены уцененные товары и товары с ограниченным сроком годност")); }
public void Import_order_xml() { var supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); Program.SupplierIdForCodeLookup = supplier.Id; var price = supplier.Prices[0]; var client = TestClient.CreateNaked(session); var address = client.Addresses[0]; var intersection = session.Query <TestAddressIntersection>().First(a => a.Address == address && a.Intersection.Price == price); intersection.SupplierDeliveryId = "02"; intersection.Intersection.SupplierClientId = "1"; session.Save(intersection); FlushAndCommit(); var root = Directory.CreateDirectory($"tmp/{client.Users[0].Id}/orders/"); using (var zip = new ZipFile()) { zip.AddEntry("1.xml", OrderPacket(price.Core.Select(x => (object)x.Id).Take(2).ToArray())); zip.Save(Path.Combine(root.FullName, "order.zip")); } Program.ProcessUser(config, client.Users[0].Id, ProtocolType.Xml); var orders = session.Query <TestOrder>().Where(x => x.Client.Id == client.Id).ToList(); Assert.AreEqual(1, orders.Count); }
public void SendWithHtmlBody() { var client = TestClient.CreateNaked(session); var user = client.Users[0]; SetUp( new List <TestUser> { user }, null, "Это письмо пользователю", "Это текст письма пользователю", null); var mimeHtml = Mime.Parse(@"..\..\Data\UnparseWithHtml.eml"); mimeHtml.MainEntity.To = _info.Mime.MainEntity.To; mimeHtml.MainEntity.From = _info.Mime.MainEntity.From; _info.Mime = mimeHtml; Process(); var mails = TestMailSendLog.Queryable.Where(l => l.User.Id == user.Id).ToList(); Assert.That(mails.Count, Is.EqualTo(1)); var mailLog = mails[0]; Assert.That(mailLog.Mail.Supplier.Id, Is.EqualTo(_info.Supplier.Id)); Assert.That(mailLog.Mail.Subject, Is.EqualTo("натура сиберика")); Assert.That(mailLog.Mail.Body, Is.StringStarting("\r\nДОБРЫЙ ДЕНЬ!\r\nНаша фирма является поставщиком и официальным представителем органической косметики Натура Сиберика. Мы уже поставляем эту косметику в вашу аптеку по ул.Советская.")); }
public void Remove_duplicate_codes() { supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); client = TestClient.CreateNaked(session); order = new TestOrder(client.Users[0], supplier.Prices[0]); order.WriteTime = order.WriteTime.AddDays(-1); var offer = supplier.Prices[0].Core[0]; order.AddItem(offer, 10); session.Save(order); Property("ProductNamePosition", 0); Property("MnnPosition", 1); Property("ByPreviousMonth", false); Property("ShowCode", true); Property("ReportInterval", 1); Property("SourceFirmCode", (int)supplier.Id); var sheet = ReadReport <MixedReport>(); var text = ToText(sheet); var row = FindRowByProduct(sheet, offer.Product); Assert.AreEqual(offer.Code, row.GetCell(0).StringCellValue, text); }
public void SendWithExclusion() { var client = TestClient.CreateNaked(session); var user = client.Users[0]; var inforoomRegion = TestRegion.Find(TestRegion.Inforoom); SetUp( new List <TestUser> { user }, inforoomRegion, "Это письмо пользователю", "Это текст письма пользователю", null); var handler = new DocSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass); handler.TestProcessMime(_info.Mime); var existsMessages = ImapHelper.CheckImapFolder(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass, ImapHelper.INBOXFolder); Assert.That(existsMessages.Count, Is.GreaterThanOrEqualTo(1), "Не найдены письма в IMAP-папке"); var responseCount = existsMessages .Count(m => m.Envelope?.Subject?.Equals(_responseSubject, StringComparison.CurrentCultureIgnoreCase) == true); Assert.That(responseCount, Is.EqualTo(1), "Не найдено письмо с загловком '{0}'", _responseSubject); var mails = TestMailSendLog.Queryable.Where(l => l.User.Id == user.Id).ToList(); Assert.That(mails.Count, Is.EqualTo(1)); var mailLog = mails[0]; Assert.That(mailLog.Mail.Supplier.Id, Is.EqualTo(_info.Supplier.Id)); }
public void ErrorOnEmptyLetter() { var client = TestClient.CreateNaked(session); var user = client.Users[0]; var supplier = TestSupplier.CreateNaked(session); var from = $"{supplier.Id}@supplier.test"; PrepareSupplier(supplier, from); var message = ImapHelper.BuildMessageWithAttachments( " ", " ", new string[] { "{0}@docs.analit.net".Format(user.AvaliableAddresses[0].Id) }, new[] { from }, null); var handler = new DocSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass); try { handler.CheckMime(message); Assert.Fail("Должно было возникнуть исключение MiniMailOnEmptyLetterException"); } catch (MiniMailOnEmptyLetterException exception) { Assert.That(exception.Template, Is.EqualTo(ResponseTemplate.MiniMailOnEmptyLetter)); SendErrorToProvider(handler, exception, message); } }
public void ErrorOnAllowedExtensions() { var client = TestClient.CreateNaked(session); var user = client.Users[0]; var supplier = TestSupplier.CreateNaked(session); var from = String.Format("{0}@supplier.test", supplier.Id); PrepareSupplier(supplier, from); var message = ImapHelper.BuildMessageWithAttachments( "test AllowedExtensions", "body AllowedExtensions", new string[] { "{0}@docs.analit.net".Format(user.AvaliableAddresses[0].Id) }, new[] { from }, new string[] { @"..\..\Data\Waybills\70983_906384.zip" }); var handler = new DocSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass); try { handler.CheckMime(message); Assert.Fail("Должно было возникнуть исключение MiniMailOnAllowedExtensionsException"); } catch (MiniMailOnAllowedExtensionsException exception) { Assert.That(exception.Template, Is.EqualTo(ResponseTemplate.MiniMailOnAllowedExtensions)); Assert.That(exception.ErrorExtention, Is.EqualTo(".zip").IgnoreCase); Assert.That(exception.AllowedExtensions, Is.EqualTo("doc, xls, gif, tiff, tif, jpg, pdf, txt").IgnoreCase); SendErrorToProvider(handler, exception, message); } }
public void TestRecipientsList() { var payer = new TestPayer("Тестовый плательщик"); session.Save(payer); var contactGroupOwner = new TestContactGroupOwner(); contactGroupOwner.SaveAndFlush(); var client1 = TestClient.CreateNaked(session); var client2 = TestClient.CreateNaked(session); client1.Payers.Add(payer); client2.Payers.Add(payer); session.CreateSQLQuery(@"INSERT INTO Billing.PayerClients(ClientId, PayerId) VALUES(:clientid1, :payerid); INSERT INTO Billing.PayerClients(ClientId, PayerId) VALUES(:clientid2, :payerid);" ) .SetParameter("clientid1", client1.Id).SetParameter("clientid2", client2.Id).SetParameter("payerid", payer.Id).ExecuteUpdate(); var repPayer = Payer.Find(payer.Id); var new_report = new GeneralReport() { Format = "Excel", Payer = repPayer, Comment = "Тестовый отчет" }; new_report.SaveAndFlush(); var reportId = new_report.Id; var report = GeneralReport.Find(Convert.ToUInt64(reportId)); Assert.That(report.Payer.AllClients.Count, Is.EqualTo(2)); Assert.That(report.Payer.Clients[0].ShortName, Is.EqualTo(client1.Name)); Assert.That(report.Payer.Clients[1].ShortName, Is.EqualTo(client2.Name)); }
public void SimpleParseMails() { var client = TestClient.CreateNaked(session); var user = client.Users[0]; SetUp( new List <TestUser> { user }, null, "Это письмо пользователю", "Это текст письма пользователю", null); Process(); var mails = TestMailSendLog.Queryable.Where(l => l.User.Id == user.Id).ToList(); Assert.That(mails.Count, Is.EqualTo(1)); var mailLog = mails[0]; Assert.That(mailLog.UpdateLogEntry, Is.Null); Assert.That(mailLog.Committed, Is.False); Assert.That(mailLog.Mail.Supplier.Id, Is.EqualTo(_info.Supplier.Id)); Assert.That(mailLog.Mail.SupplierEmail, Is.Not.Null.Or.Empty); Assert.That(mailLog.Mail.SupplierEmail, Is.EqualTo("{0}@supplier.test".Format(_info.Supplier.Id))); Assert.That(mailLog.Mail.MailRecipients.Count, Is.GreaterThan(0)); Assert.That(mailLog.Mail.Subject, Is.EqualTo("Это письмо пользователю")); Assert.That(mailLog.Mail.Body, Is.EqualTo("Это текст письма пользователю")); Assert.That(mailLog.Mail.IsVIPMail, Is.False); Assert.That(mailLog.Mail.Attachments.Count, Is.EqualTo(0)); Assert.That(mailLog.Mail.SHA256Hash, Is.Not.Null.Or.Empty); }
public void SendVIPMail() { var client = TestClient.CreateNaked(session); var user = client.Users[0]; SetUp( new List <TestUser> { user }, null, "Это письмо пользователю", "Это текст письма пользователю", null); var handler = new DocSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass); TemplateHolder.Values.VIPMailPayerId = _info.Supplier.Payer.Id; handler.TestProcessMime(_info.Mime); var mails = TestMailSendLog.Queryable.Where(l => l.User.Id == user.Id).ToList(); Assert.That(mails.Count, Is.EqualTo(1)); var mailLog = mails[0]; Assert.That(mailLog.UpdateLogEntry, Is.Null); Assert.That(mailLog.Committed, Is.False); Assert.That(mailLog.Mail.Supplier.Id, Is.EqualTo(_info.Supplier.Id)); Assert.That(mailLog.Mail.IsVIPMail, Is.True); }
public void Group_by_code_and_product() { var code = new string(Guid.NewGuid().ToString().Take(20).ToArray()); var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var price = supplier.Prices[0]; var order = new TestOrder(client.Users[0], price) { WriteTime = DateTime.Now.AddDays(-5) }; var productSynonym = price.AddProductSynonym(TestProduct.Random(session).First()); session.Save(productSynonym); var item = order.AddItem(TestProduct.RandomProducts(session).First(), 10, 456); item.SynonymCode = productSynonym.Id; item.Code = code; session.Save(order); Property("ReportInterval", 5); Property("SupplierProductCodePosition", 0); Property("SupplierProductNamePosition", 1); Property("FirmCodeEqual", new List <ulong> { supplier.Id }); var sheet = ReadReport <RatingReport>(); Assert.AreEqual("Оригинальный код товара", sheet.GetRow(2).GetCell(0).StringCellValue); Assert.AreEqual(code, sheet.GetRow(3).GetCell(0).StringCellValue); Assert.AreEqual("Оригинальное наименование товара", sheet.GetRow(2).GetCell(1).StringCellValue); Assert.AreEqual(productSynonym.Name, sheet.GetRow(3).GetCell(1).StringCellValue); }
public void Generate_report() { var code = new string(Guid.NewGuid().ToString().Take(20).ToArray()); var supplier = TestSupplier.CreateNaked(session); var client = TestClient.CreateNaked(session); var price = supplier.Prices[0]; var order = new TestOrder(client.Users[0], price) { WriteTime = DateTime.Now.AddDays(-5) }; var productSynonym = price.AddProductSynonym(TestProduct.Random(session).First()); session.Save(productSynonym); var item = order.AddItem(TestProduct.RandomProducts(session).First(), 10, 456); item.SynonymCode = productSynonym.Id; item.Code = code; session.Save(order); Property("ReportInterval", 5); Property("SupplierId", supplier.Id); Property("Regions", new List <ulong> { client.RegionCode }); var AFCode = $"{item.Product.Id}_{item.CodeFirmCr ?? 0}"; var sheet = ReadReport <PulsOrderReport>(); var text = ToText(sheet); Assert.That(text, Does.Contain(AFCode)); }
public void Build_excel_report() { var supplier = TestSupplier.CreateNaked(session); var product = session.Query <TestProduct>().First(p => p.CatalogProduct.Pharmacie); var core1 = supplier.AddFullCore(session, product); var core2 = supplier.AddFullCore(session, product, session.Query <TestProducer>().First()); core2.Code = Generator.Random().First().ToString(); var client = TestClient.CreateNaked(session); session.CreateSQLQuery("delete from Customers.UserPrices where PriceId <> :priceId and UserId = :userId") .SetParameter("priceId", supplier.Prices[0].Id) .SetParameter("userId", client.Users[0].Id) .ExecuteUpdate(); Property("ReportType", (int)DefReportType.ByNameAndFormAndFirmCr); Property("RegionEqual", new List <ulong> { client.RegionCode }); Property("ClientCode", client.Id); Property("UserCode", client.Users[0].Id); Property("PriceCode", supplier.Prices[0].Id); var report = ReadReport <DefReport>(); var result = ToText(report); Assert.That(result, Does.Contain("|Код|Наименование|Форма выпуска|Производитель|")); }
public void Region_filter() { var supplier = TestSupplier.CreateNaked(session); supplier.AddRegion(session.Load <TestRegion>(512ul)); var client = TestClient.CreateNaked(session, 512, 512); var order = CreateOrder(client, supplier); session.Save(order); var client1 = TestClient.CreateNaked(session); var order1 = CreateOrder(client1, supplier); session.Save(order1); Property("ReportInterval", 7); Property("ByPreviousMonth", false); Property("RegionEqual", new List <long> { 512 }); var report = ReadReport <OrdersStatistics>(); var result = ToText(report); Assert.That(result, Is.Not.StringContaining("Воронеж")); }
public void PrepareDublicateMessage() { string subject = "Тест на дубликаты"; string body = "Дублирующее сообщение"; var client = TestClient.CreateNaked(session); var user = client.Users[0]; SetUp( new List <TestUser> { user }, null, subject, body, null); var filter = new EventFilter <DocSourceHandlerForTesting>(log4net.Core.Level.All); var handler = new DocSourceHandlerForTesting(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass, true); handler.CreateDirectoryPath(); //вызываем обработку первый раз handler.ProcessMime(this._info.Mime); //вызываем обработку второй раз handler.ProcessMime(this._info.Mime); //проверяем, был ли вызван перекрытый метод отправки письма Assert.That(handler.MessageSended, Is.EqualTo(false)); //смотрим, пришло ли сообщение в лог Assert.That(filter.Events.Count, Is.EqualTo(1)); //смотрим, содержит ли строка сообщения заголовок письма Assert.That(filter.Events[0].GetLoggingEventData().Message.Contains(subject), Is.EqualTo(true)); }
public void Ignore_unknown_producers() { var supplier = TestSupplier.CreateNaked(session); var product = session.Query <TestProduct>().First(p => p.CatalogProduct.Pharmacie); var core1 = supplier.AddFullCore(session, product); var core2 = supplier.AddFullCore(session, product, session.Query <TestProducer>().First()); core2.Code = Generator.Random().First().ToString(); var client = TestClient.CreateNaked(session); session.CreateSQLQuery("delete from Customers.UserPrices where PriceId <> :priceId and UserId = :userId") .SetParameter("priceId", supplier.Prices[0].Id) .SetParameter("userId", client.Users[0].Id) .ExecuteUpdate(); Property("ReportType", (int)DefReportType.ByNameAndFormAndFirmCr); Property("RegionEqual", new List <ulong> { client.RegionCode }); Property("ClientCode", client.Id); Property("UserCode", client.Users[0].Id); Property("PriceCode", supplier.Prices[0].Id); ProcessReport(typeof(DefReport)); var data = report.GetReportTable(); Assert.AreEqual(1, data.Rows.Count, String.Format("клиент {0} поставщик {1}", client.Id, supplier.Id)); Assert.AreEqual(core2.Code, data.Rows[0]["Code"]); }
public void SetUp() { var priceParent = TestSupplier.CreateNaked(session).Prices[0]; var price = TestSupplier.CreateNaked(session).Prices[0]; price.ParentSynonym = priceParent.Id; Save(price); _supplier = price.Supplier; var client = TestClient.CreateNaked(session); var testAddress = client.Addresses[0]; var order = new TestOrder(); _product = new TestProduct("Виагра (табл.)"); _product.CatalogProduct.Pharmacie = true; session.Save(_product); _producer = new TestProducer("Пфайзер"); session.Save(_producer); session.Save(new TestSynonym() { Synonym = "Виагра", ProductId = _product.Id, PriceCode = (int?)price.Id }); session.Save(new TestSynonymFirm() { Synonym = "Пфайзер", CodeFirmCr = (int?)_producer.Id, PriceCode = (int?)price.Id }); TestAssortment.CheckAndCreate(session, _product, _producer); var log = new DocumentReceiveLog(session.Load <Supplier>(_supplier.Id), session.Load <Address>(testAddress.Id)) { MessageUid = 123, DocumentSize = 100 }; _doc = new Document(log) { OrderId = order.Id, Address = log.Address, DocumentDate = DateTime.Now }; _supplierCode = new SupplierCode { Code = "45678", Supplier = session.Load <Supplier>(_supplier.Id), ProducerId = _producer.Id, Product = session.Load <Product>(_product.Id), CodeCr = string.Empty }; session.Save(_supplierCode); // сопоставляется по коду _documentLine = _doc.NewLine(); _documentLine.Product = "Виагра"; _documentLine.Producer = " Тестовый производитель "; _documentLine.Code = "45678"; }