public static List <DocumentReceiveLog> GetFilesForParsing(ISession session, params string[] filePaths) { var client = TestClient.Create(session); var supplier = TestSupplier.Create(session); var resultList = new List <uint>(); foreach (var filePath in filePaths) { var file = filePath; if (!File.Exists(file)) { file = Path.Combine(@"..\..\Data\Waybills\multifile", filePath); } var log = new TestDocumentLog(supplier, client, Path.GetFileName(filePath)); session.Save(log); resultList.Add(log.Id); var clientDir = Path.Combine(Settings.Default.DocumentPath, log.Address.Id.ToString().PadLeft(3, '0')); var documentDir = Path.Combine(clientDir, DocumentType.Waybill + "s"); var name = String.Format("{0}_{1}({2}){3}", log.Id, supplier.Name, Path.GetFileNameWithoutExtension(file), Path.GetExtension(file)); Common.Tools.FileHelper.CreateDirectoryRecursive(documentDir); File.Copy(file, Path.Combine(documentDir, name)); } return(DocumentReceiveLog.LoadByIds(resultList.ToArray())); }
protected IOktaClient GetClient(string scenarioName) { // scenarioName is reserved for future use, if we add // mocked server responses to our testing strategy. return(TestClient.Create()); }
public async Task Should_Wait_For_Collection() { var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); var request = TestClient.Create(_logger).Net .WaitForCollectionAsync(new ParamsOfWaitForCollection { Collection = "transactions", Filter = new { now = new { gt = now } }.ToJson(), Result = "id now" }); await Task.Delay(TimeSpan.FromSeconds(1)); var task = _client.GetGramsFromGiverAsync(TonClientNodeSe.GiverAddress); var result = await request; Assert.NotNull(result); await task; }
public void Hide_header() { var supplier1 = TestSupplier.Create(session); supplier1.CreateSampleCore(session); var supplier2 = TestSupplier.Create(session); supplier2.CreateSampleCore(session); var client = TestClient.Create(session); Property("ReportType", 2); Property("RegionEqual", new List <ulong> { 1 }); Property("ClientCode", client.Id); Property("ReportIsFull", false); Property("ReportSortedByPrice", false); Property("ShowPercents", true); Property("CalculateByCatalog", false); Property("PriceCode", (int)supplier1.Prices[0].Id); Property("ByWeightCosts", false); Property("HideHeader", true); TryInitReport <SpecReport>(); var sheet = ReadReport(); var text = ToText(sheet); Assert.That(text, Does.Not.Contains("Специальный отчет по взвешенным ценам по данным на")); Assert.That(text, Does.Not.Contains(supplier2.Name)); }
public void Hide_all_except4() { var supplier1 = TestSupplier.Create(session); supplier1.CreateSampleCore(session); var supplier2 = TestSupplier.Create(session); supplier2.CreateSampleCore(session); var client = TestClient.Create(session); Property("ReportType", 3); Property("RegionEqual", new List <ulong> { 1 }); Property("ClientCode", client.Id); Property("ReportIsFull", false); Property("ReportSortedByPrice", false); Property("ShowPercents", false); Property("CalculateByCatalog", false); Property("PriceCode", (int)supplier1.Prices[0].Id); Property("ByWeightCosts", false); Property("HideHeader", false); Property("HideAllExcept4", true); TryInitReport <SpecReport>(); var sheet = ReadReport(); var text = ToText(sheet); Assert.That(text, Does.Not.Contains("Макс. цена")); }
public void SetUp() { TestHelper.RecreateDirectories(); var supplierFtpSources = TestWaybillSource.Queryable.Where(source => source.SourceType == TestWaybillSourceType.FtpSupplier); foreach (var source in supplierFtpSources) { source.SourceType = TestWaybillSourceType.ForTesting; source.Update(); } handler = new WaybillFtpSourceHandler(); ftpHost = "127.0.0.1"; ftpPort = Generator.Random(Int16.MaxValue).First(); ftpWaybillDirectory = "Waybills"; ftpRejectDirectory = "Rejects"; user = "******"; password = "******"; supplierDeliveryId = 1234u; supplier = CreateAndSetupSupplier(ftpHost, ftpPort, ftpWaybillDirectory, ftpRejectDirectory, user, password); client = TestClient.Create(session); session.Save(client); address = client.Addresses[0]; CopyWaybillFiles(); }
public virtual async Task InitAsync(ILogger logger) { Client = TestClient.Create(logger); Keys = await Client.Crypto.GenerateRandomSignKeysAsync(); (Abi, Tvc) = TestClient.Package(Name); Address = await Client.DeployWithGiverAsync(new ParamsOfEncodeMessage { Abi = Abi, DeploySet = new DeploySet { Tvc = Tvc }, Signer = new Signer.Keys { KeysProperty = Keys }, CallSet = new CallSet { FunctionName = "constructor", Input = await GetConstructorParamsAsync() } }); await SetAbiAsync(); }
public void Setup() { client = TestClient.Create(2, 2); address = client.Addresses[0]; source.SourceType = PriceSourceType.Email; source.Save(); ImapHelper.ClearImapFolder(Settings.Default.TestIMAPUser, Settings.Default.TestIMAPPass, Settings.Default.IMAPSourceFolder); }
public void SetUp() { orders = new List <OrderHead>(); client = TestClient.Create(session); var testAddress = client.Addresses[0]; address = Address.Find(testAddress.Id); var supplier = TestSupplier.Create(session); price = supplier.Prices[0]; appSupplier = Supplier.Find(supplier.Id); }
public void Setup() { client = TestClient.Create(session); testAddress = client.Addresses[0]; address = Address.Find(testAddress.Id); settings = WaybillSettings.Find(client.Id); supplier = TestSupplier.CreateNaked(session); price = supplier.Prices[0]; appSupplier = Supplier.Find(supplier.Id); docRoot = Path.Combine(Settings.Default.DocumentPath, address.Id.ToString()); waybillsPath = Path.Combine(docRoot, "Waybills"); Directory.CreateDirectory(waybillsPath); }
public void CheckExistsClient() { var client = TestClient.Create(session); var recipient = MailRecipient.Parse(client.Id + "@client.docs.analit.net"); Assert.That(recipient, Is.Not.Null); Assert.That(recipient.Email, Is.EqualTo(client.Id + "@client.docs.analit.net")); Assert.That(recipient.Type, Is.EqualTo(RecipientType.Client)); Assert.That(recipient.Address, Is.Null); Assert.That(recipient.Region, Is.Null); Assert.That(recipient.Client, Is.Not.Null); Assert.That(recipient.Client.Id, Is.EqualTo(client.Id)); Assert.That(recipient.Status, Is.EqualTo(RecipientStatus.Verified)); }
public void Build() { var supplier = TestSupplier.CreateNaked(session); supplier.CreateSampleCore(session); var client = TestClient.Create(session); var report = new CombReport((MySqlConnection)session.Connection, properties); report.ClientCode = (int)client.Id; report.Configured = true; var sheet = ReadReport(report); Assert.That(ToText(sheet), Does.Contain("Комбинированный отчет без учета производителя")); }
public async Task Should_Set_Endpoints() { var client = TestClient.Create(); await client.Net.SetEndpointsAsync(new EndpointsSet { Endpoints = new[] { "cinet.tonlabs.io", "cinet2.tonlabs.io/" } }); var result = await client.Net.FetchEndpointsAsync(); Assert.NotNull(result); Assert.Equal(2, result.Endpoints.Length); Assert.Contains("https://cinet.tonlabs.io/", result.Endpoints); Assert.Contains("https://cinet2.tonlabs.io/", result.Endpoints); }
static void Main(string[] args) { List <BankAccount> accounts = new List <BankAccount>(); while (true) { var input = Console.ReadLine() .Split(' ') .ToArray(); var command = input[0]; if (command == "End") { break; } int[] commandArgs = input.Skip(1) .Select(int.Parse) .ToArray(); int id = commandArgs[0]; int amount = 0; switch (command) { case "Create": TestClient.Create(id, accounts); break; case "Deposit": amount = commandArgs[1]; TestClient.Deposit(id, amount, accounts); break; case "Withdraw": amount = commandArgs[1]; TestClient.Withdraw(id, amount, accounts); break; case "Print": TestClient.Print(id, accounts); break; } } }
public void SetUp() { _testSupplier = TestSupplier.Create(); _realSupplier = session.Query <Supplier>().FirstOrDefault(s => s.Id == _testSupplier.Id); var certificateSources = session.Query <CertificateSource>().Where(s => s.SourceClassName == typeof(RostaCertificateSource).Name).ToList(); certificateSources.ForEach(c => session.Delete(c)); _source = new CertificateSource { SourceClassName = typeof(RostaCertificateSource).Name }; _source.Suppliers = new List <Supplier>(); _source.Suppliers.Add(_realSupplier); session.Save(_source); _testUser = TestClient.Create().Users[0]; }
public void CheckDisabledAddress() { var client = TestClient.Create(session); var address = client.Addresses[0]; address.Enabled = false; address.Save(); var recipient = MailRecipient.Parse(address.Id + "@docs.analit.net"); Assert.That(recipient, Is.Not.Null); Assert.That(recipient.Email, Is.EqualTo(address.Id + "@docs.analit.net")); Assert.That(recipient.Type, Is.EqualTo(RecipientType.Address)); Assert.That(recipient.Address, Is.Not.Null); Assert.That(recipient.Region, Is.Null); Assert.That(recipient.Client, Is.Null); Assert.That(recipient.Address.Id, Is.EqualTo(address.Id)); Assert.That(recipient.Status, Is.EqualTo(RecipientStatus.Disabled)); }
public void Enable_price_for_client_with_supplier_client_id() { var trustedClient = TestClient.Create(); var normalClient = TestClient.Create(); var price = prices[1]; using (new SessionScope()) { var trustedIntersection = TestIntersection.Queryable.Single(i => i.Price == price && i.Client == trustedClient); trustedIntersection.SupplierClientId = "3273"; trustedIntersection.PriceMarkup = -1; trustedIntersection.Save(); } Formalize("FarmaimpeksSmallPrice.xml"); using (new SessionScope()) { var regularIntersection = TestIntersection.Queryable.Single(i => i.Price == price && i.Client == normalClient); Assert.That(regularIntersection.AvailableForClient, Is.False); var trustedIntersection = TestIntersection.Queryable.Single(i => i.Price == price && i.Client == trustedClient); Assert.That(trustedIntersection.AvailableForClient, Is.True); } }
public void OneTimeSetUp() { _server = new TestServer(); _client = TestClient.Create(_server.Port); }
public ProcessingModuleTests(ITestOutputHelper outputHelper) { _client = TestClient.Create(new XUnitTestLogger(outputHelper)); }
public CryptoModuleTests(ITestOutputHelper outputHelper) { _client = TestClient.Create(new XUnitTestLogger(outputHelper)); }
public void Apply_settings() { xml = @"<PriceAndSettings> <Settings> <Group> <ClientId>122221</ClientId> <PayerId>21</PayerId> <CostId>PRICE6</CostId> <Markup>10</Markup> <Available>1</Available> <Address> <AddressId>122224</AddressId> <ControlMinReq>0</ControlMinReq> <MinReq>3000</MinReq> </Address> </Group> </Settings> <Price> <Item> <Code>109054</Code> <Product>Маска трехслойная на резинках медицинская Х3 Инд. уп. И/м</Product> <Producer>Вухан Лифарма Кемикалз Ко</Producer> <Volume>400</Volume> <Quantity>296</Quantity> <Period>01.01.2013</Period> <VitallyImportant>0</VitallyImportant> <NDS>10</NDS> <RequestRatio>20</RequestRatio> <Cost> <Id>PRICE6</Id> <Value>10.10</Value> <MinOrderCount>20</MinOrderCount> </Cost> <Cost> <Id>PRICE1</Id> <Value>10.0</Value> <MinOrderCount>20</MinOrderCount> </Cost> </Item> </Price> </PriceAndSettings>"; var client = TestClient.Create(session); var intersections = TestIntersection.Queryable.Where(i => i.Client == client && i.Price == price).ToList(); Assert.That(intersections.Count, Is.EqualTo(1)); var intersection = intersections[0]; intersection.SupplierClientId = "122221"; intersection.SupplierPaymentId = "21"; intersection.AddressIntersections[0].SupplierDeliveryId = "122224"; Formalize(); session.Refresh(intersection); Assert.That(intersection.Cost.Name, Is.EqualTo("PRICE6")); Assert.That(intersection.AvailableForClient, Is.True); Assert.That(intersection.PriceMarkup, Is.EqualTo(10)); var addressintersection = intersection.AddressIntersections[0]; session.Refresh(addressintersection); Assert.That(addressintersection.MinReq, Is.EqualTo(3000)); }
public async Task Should_Suspend_Resume() { var keys = await _client.Crypto.GenerateRandomSignKeysAsync(); var(abi, tvc) = TestClient.Package("Hello"); var deployParams = new ParamsOfEncodeMessage { Abi = abi, DeploySet = new DeploySet { Tvc = tvc }, Signer = new Signer.Keys { KeysProperty = keys }, CallSet = new CallSet { FunctionName = "constructor" } }; var msg = await _client.Abi.EncodeMessageAsync(deployParams); var address = msg.Address; var transactionIds = new List <string>(); var notifications = new List <ClientError>(); var subscriptionClient = TestClient.Create(_logger); var handle = await subscriptionClient.Net.SubscribeCollectionAsync(new ParamsOfSubscribeCollection { Collection = "transactions", Filter = new { account_addr = new { eq = address }, status = new { eq = 3 } // Finalized }.ToJson(), Result = "id account_addr" }, (json, result) => { switch (result) { case 100: // OK transactionIds.Add((string)json.SelectToken("result.id")); break; case 101: // Error var clientError = new TonSerializer(_logger).Deserialize <ClientError>(json); notifications.Add(clientError); break; default: throw new NotSupportedException($"Response code ${result} not supported"); } return(Task.CompletedTask); }); // send grams to create first transaction await _client.GetGramsFromGiverAsync(msg.Address); await Task.Delay(TimeSpan.FromSeconds(1)); // check that transaction is received Assert.Single(transactionIds); // and no error notifications Assert.Empty(notifications); // suspend subscription await subscriptionClient.Net.SuspendAsync(); // deploy to create second transaction await _client.Processing.ProcessMessageAsync(new ParamsOfProcessMessage { MessageEncodeParams = deployParams, SendEvents = false }); // create second subscription while network is suspended var handle2 = await subscriptionClient.Net.SubscribeCollectionAsync(new ParamsOfSubscribeCollection { Collection = "transactions", Filter = new { account_addr = new { eq = msg.Address }, status = new { eq = 3 } // Finalized }.ToJson(), Result = "id account_addr" }, (json, result) => { switch (result) { case 100: // OK transactionIds.Add((string)json.SelectToken("result.id")); break; case 101: // Error var clientError = new TonSerializer(_logger).Deserialize <ClientError>(json); notifications.Add(clientError); break; default: throw new NotSupportedException($"Response code ${result} not supported"); } return(Task.CompletedTask); }); await Task.Delay(TimeSpan.FromMilliseconds(500)); // check that second transaction is not received when subscription suspended Assert.Single(transactionIds); Assert.Equal(2, notifications.Count); Assert.All(notifications, n => Assert.Equal((uint)NetErrorCode.NetworkModuleSuspended, n.Code)); // resume subscription await subscriptionClient.Net.ResumeAsync(); // run contract function to create new transaction await subscriptionClient.Processing.ProcessMessageAsync(new ParamsOfProcessMessage { MessageEncodeParams = new ParamsOfEncodeMessage { Abi = abi, Signer = new Signer.Keys { KeysProperty = keys }, Address = msg.Address, CallSet = new CallSet { FunctionName = "touch" } }, SendEvents = false }); // give some time for subscription to receive all data await Task.Delay(TimeSpan.FromSeconds(10)); // check that third transaction is now received after resume Assert.Equal(3, transactionIds.Count); Assert.Equal(2, transactionIds.Distinct().Count()); // and both subscriptions received notification about resume Assert.Equal(4, notifications.Count); Assert.Equal(2, notifications.Count(n => n.Code == (uint)NetErrorCode.NetworkModuleSuspended)); Assert.Equal(2, notifications.Count(n => n.Code == (uint)NetErrorCode.NetworkModuleResumed)); await subscriptionClient.Net.UnsubscribeAsync(handle); await subscriptionClient.Net.UnsubscribeAsync(handle2); }
public NetModuleTests(ITestOutputHelper outputHelper) { _logger = new XUnitTestLogger(outputHelper); _client = TestClient.Create(_logger); }
public void Setup() { testSupplier = TestSupplier.Create(); testUser = TestClient.Create().Users[0]; supplier = Supplier.Find(testSupplier.Id); }