public async Task CreatePledgeClientAndApiConsumer(string purpose)
        {
            ApiConsumer consumer = new ApiConsumer(_blueApiAppSettings);
            await consumer.RegisterNewUser();

            AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(consumer.ClientInfo.Account.Id));
            PledgeApiConsumers.Add(purpose, consumer);
        }
        private async Task <List <ApiConsumer> > RegisterNUsers(int n)
        {
            List <ApiConsumer> result = new List <ApiConsumer>();

            for (int i = 0; i < n; i++)
            {
                ApiConsumer consumer = new ApiConsumer(_blueApiAppSettings);
                await consumer.RegisterNewUser();

                AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(consumer.ClientInfo.Account.Id));
                result.Add(consumer);
            }

            return(result);
        }
        public async Task CreateTestPartnerClient()
        {
            await ClientAccountConsumer.RegisterNewUser(
                new ClientRegisterDTO
            {
                Email        = Helpers.RandomString(8) + GlobalConstants.AutoTestEmail,
                FullName     = Helpers.RandomString(5) + " " + Helpers.RandomString(8),
                ContactPhone = Helpers.Random.Next(1000000, 9999999).ToString(),
                Password     = Helpers.RandomString(10),
                Hint         = Helpers.RandomString(3),
                PartnerId    = _blueApiAppSettings.TestPartnerId  //  "NewTestPartner"
            }
                );

            AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(ClientAccountConsumer.ClientInfo.Account.Id));
        }
        private async Task PrepareTestData()
        {
            var TestClient = await Consumer.RegisterNewUser();

            TestClientId = TestClient.Account.Id;
            var walletsFromDB    = this.WalletRepository.GetAllAsync(w => w.ClientId == TestClientId && w.State != "deleted");
            var operationsFromDB = this.OperationsRepository.GetAllAsync(o => o.PartitionKey == OperationsEntity.GeneratePartitionKey() && o.ClientId.ToString() == TestClientId);

            this.TestAssetId      = Constants.TestAssetId;
            this.AssetPrecission  = 2;
            this.AllWalletsFromDb = (await walletsFromDB).Cast <WalletEntity>().ToList();
            this.TestWallet       = await CreateTestWallet();

            //fill wallet with funds
            await MEConsumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestWallet.Id, Constants.TestAssetId, 50.0);

            this.TestWalletWithBalanceId = TestWallet.Id;


            this.TestWalletDelete = await CreateTestWallet();

            this.TestWalletAccount = await AccountRepository.TryGetAsync(TestWallet.Id) as AccountEntity;

            this.TestWalletOperations = await CreateTestWallet();

            this.TestWalletRegenerateKey = await CreateTestWallet(true);

            this.TestOperation = await CreateTestOperation();

            this.TestOperationCancel = await CreateTestOperation();

            this.TestOperationCreateDetails = await CreateTestOperation();

            this.TestOperationRegisterDetails = await CreateTestOperation();


            this.ClientInfoConsumer = new ApiConsumer(_apiV2Settings);
            await this.ClientInfoConsumer.RegisterNewUser();

            AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(ClientInfoConsumer.ClientInfo.Account.Id));

            // set the id to the default one in case it has been changed by any test
            BaseAssetDTO body     = new BaseAssetDTO(this.TestAssetId);
            var          response = await Consumer.ExecuteRequest(ApiPaths.ASSETS_BASEASSET_PATH, Helpers.EmptyDictionary, JsonUtils.SerializeObject(body), Method.POST);
        }
Beispiel #5
0
        public async Task CreateLykkeBluePartnerClientAndApiConsumer()
        {
            var consumer = new ApiConsumer(_configBuilder);

            await consumer.RegisterNewUser(
                new ClientRegisterDTO
            {
                Email        = Helpers.RandomString(8) + GlobalConstants.AutoTestEmail,
                FullName     = Helpers.RandomString(5) + " " + Helpers.RandomString(8),
                ContactPhone = Helpers.Random.Next(1000000, 9999999).ToString(),
                Password     = Helpers.RandomString(10),
                Hint         = Helpers.RandomString(3),
                PartnerId    = _configBuilder.Config["LykkeBluePartnerId"]  // "Lykke.blue"
            }
                );

            AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(consumer.ClientInfo.Account.Id));
        }
Beispiel #6
0
        private async Task prepareTestData()
        {
            ConfigBuilder apiv2Config          = new ConfigBuilder("ApiV2");
            ApiConsumer   registerConsumer1    = new ApiConsumer(apiv2Config);
            ApiConsumer   registerConsumer2    = new ApiConsumer(apiv2Config);
            var           registerTestAccount1 = registerConsumer1.RegisterNewUser();
            var           registerTestAccount2 = registerConsumer2.RegisterNewUser();

            TestAsset1 = Constants.TestAsset1;
            TestAsset2 = Constants.TestAsset2;

            TestAccountId1 = (await registerTestAccount1)?.Account.Id;
            TestAccountId2 = (await registerTestAccount2)?.Account.Id;

            AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(TestAccountId1));
            AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(TestAccountId2));

            //give test clients some cash to work with
            List <Task> giveCashTasks = new List <Task>()
            {
                Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId1, TestAsset1, Constants.InitialAssetAmmount),
                Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId1, TestAsset2, Constants.InitialAssetAmmount),
                Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId2, TestAsset1, Constants.InitialAssetAmmount),
                Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId2, TestAsset2, Constants.InitialAssetAmmount)
            };

            if (!Int32.TryParse(_configBuilder.Config["AssetPrecission"], out AssetPrecission))
            {
                AssetPrecission = 2;
            }

            this.TestAssetPair = (AssetPairEntity)Task.Run(async() =>
            {
                return(await this.AssetPairsRepository.TryGetAsync(TestAsset1 + TestAsset2));
            }).Result;

            await Task.WhenAll(giveCashTasks);
        }