private async Task prepareTestData() { ApiConsumer registerConsumer = new ApiConsumer(new ConfigBuilder("BlueApi")); this.TestClient = await registerConsumer.RegisterNewUser(); await ClientAccounts.FillWalletWithAsset(TestClient.Account.Id, Constants.BALANCES_ASSET_ID, Constants.BALANCES_ASSET_AMOUNT); }
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); }
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)); }
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); }
private async Task prepareTestData() { MapperConfiguration config = new MapperConfiguration(cfg => { cfg.CreateMap <AssetEntity, AssetDTO>(); cfg.CreateMap <AssetDTO, AssetEntity>(); cfg.CreateMap <AssetCategoryEntity, AssetCategoryDTO>(); cfg.CreateMap <AssetCategoryDTO, AssetCategoryEntity>(); cfg.CreateMap <AssetExtendedInfosEntity, AssetExtendedInfoDTO>(); cfg.CreateMap <AssetExtendedInfoDTO, AssetExtendedInfosEntity>(); cfg.CreateMap <AssetGroupDTO, AssetGroupEntity>(); cfg.CreateMap <AssetGroupEntity, AssetGroupDTO>(); cfg.CreateMap <AssetPairDTO, AssetPairEntity>(); cfg.CreateMap <AssetPairEntity, AssetPairDTO>(); cfg.CreateMap <AssetIssuerDTO, AssetIssuersEntity>(); cfg.CreateMap <AssetIssuersEntity, AssetIssuerDTO>(); cfg.CreateMap <MarginAssetPairDTO, MarginAssetPairsEntity>(); cfg.CreateMap <MarginAssetPairsEntity, MarginAssetPairDTO>(); cfg.CreateMap <MarginAssetDTO, MarginAssetEntity>(); cfg.CreateMap <MarginAssetEntity, MarginAssetDTO>(); cfg.CreateMap <MarginIssuerDTO, MarginIssuerEntity>(); cfg.CreateMap <MarginIssuerEntity, MarginIssuerDTO>(); cfg.CreateMap <WatchListDTO, WatchListEntity>(); cfg.CreateMap <WatchListEntity, WatchListDTO>(); cfg.CreateMap <AssetSettingsDTO, AssetSettingsEntity>(); cfg.CreateMap <AssetSettingsEntity, AssetSettingsDTO>(); cfg.CreateMap <AssetSettingsDTO, AssetSettingsCreateDTO>(); cfg.CreateMap <AssetSettingsCreateDTO, AssetSettingsDTO>(); cfg.CreateMap <Erc20TokenEntity, Erc20TokenDto>().ReverseMap(); }); this.mapper = config.CreateMapper(); var assetsFromDB = AssetRepository.GetAllAsync( a => a.PartitionKey == AssetEntity.GeneratePartitionKey() && a.Type != "Erc20Token"); var AssetExtInfoFromDB = AssetExtendedInfosManager.GetAllAsync(); var assetsAttrFromDB = AssetAttributesManager.GetAllAsync(); var assetsCatsFromDB = AssetCategoryManager.GetAllAsync(); var assetsGroupsFromDB = AssetGroupsManager.GetAllAsync(); var assetPairsFromDB = AssetPairManager.GetAllAsync(); var assetSettingsFromDB = AssetSettingsManager.GetAllAsync(); var assetIssuersFromDB = AssetIssuersManager.GetAllAsync(); var marginAssetPairsFromDB = MarginAssetPairManager.GetAllAsync(); var marginAssetsFromDB = MarginAssetManager.GetAllAsync(); var marginIssuersFromDB = MarginIssuerManager.GetAllAsync(); var watchListsFromDB = WatchListRepository.GetAllAsync(); this.AllAssetsFromDB = (await assetsFromDB).Cast <AssetEntity>().ToList(); this.TestAsset = EnumerableUtils.PickRandom(AllAssetsFromDB); this.AllAssetExtendedInfosFromDB = (await AssetExtInfoFromDB).Cast <AssetExtendedInfosEntity>().ToList(); this.TestAssetExtendedInfo = EnumerableUtils.PickRandom(AllAssetExtendedInfosFromDB); this.AllAssetAttributesFromDB = (await assetsAttrFromDB).Cast <AssetAttributesEntity>().ToList(); this.TestAssetAttribute = EnumerableUtils.PickRandom(AllAssetAttributesFromDB); this.AllAssetCategoriesFromDB = (await assetsCatsFromDB).Cast <AssetCategoryEntity>().ToList(); this.TestAssetCategory = EnumerableUtils.PickRandom(AllAssetCategoriesFromDB); this.AllAssetGroupsFromDB = (await assetsGroupsFromDB).Cast <AssetGroupEntity>().ToList(); this.TestAssetGroup = EnumerableUtils.PickRandom(AllAssetGroupsFromDB); this.AllAssetPairsFromDB = (await assetPairsFromDB).Cast <AssetPairEntity>().ToList(); this.TestAssetPair = EnumerableUtils.PickRandom(AllAssetPairsFromDB); ConfigBuilder apiv2Config = new ConfigBuilder("ApiV2"); ApiConsumer registerConsumer1 = new ApiConsumer(apiv2Config); ApiConsumer registerConsumer2 = new ApiConsumer(apiv2Config); var registeredAccount1 = registerConsumer1.RegisterNewUser(); var registeredAccount2 = registerConsumer2.RegisterNewUser(); this.TestAccountId = (await registeredAccount1)?.Account.Id; this.TestAccountIdForClientEndpoint = (await registeredAccount2)?.Account.Id; this.TestGroupForClientEndpoint = await CreateTestAssetGroup(); this.TestAssetForClientEndpoint = await CreateTestAsset(); await AddClientToGroup(TestAccountIdForClientEndpoint, TestGroupForClientEndpoint.Name); await AddAssetToGroup(TestAssetForClientEndpoint.Id, TestGroupForClientEndpoint.Name); this.AllAssetSettingsFromDB = (await assetSettingsFromDB).Cast <AssetSettingsEntity>().ToList(); this.TestAssetSettings = EnumerableUtils.PickRandom(AllAssetSettingsFromDB); this.AllAssetIssuersFromDB = (await assetIssuersFromDB).Cast <AssetIssuersEntity>().ToList(); this.TestAssetIssuer = EnumerableUtils.PickRandom(AllAssetIssuersFromDB); this.AllMarginAssetPairsFromDB = (await marginAssetPairsFromDB).Cast <MarginAssetPairsEntity>().ToList(); this.TestMarginAssetPair = EnumerableUtils.PickRandom(AllMarginAssetPairsFromDB); this.AllMarginAssetsFromDB = (await marginAssetsFromDB).Cast <MarginAssetEntity>().ToList(); this.TestMarginAsset = EnumerableUtils.PickRandom(AllMarginAssetsFromDB); this.AllMarginIssuersFromDB = (await marginIssuersFromDB).Cast <MarginIssuerEntity>().ToList(); this.TestMarginIssuer = EnumerableUtils.PickRandom(AllMarginIssuersFromDB); this.AllWatchListsFromDB = (await watchListsFromDB).Cast <WatchListEntity>().ToList(); this.AllWatchListsFromDBPredefined = AllWatchListsFromDB.Where(e => e.PartitionKey == "PublicWatchList").ToList(); this.TestWatchListPredefined = EnumerableUtils.PickRandom(AllWatchListsFromDBPredefined); this.AllWatchListsFromDBCustom = AllWatchListsFromDB.Where(e => e.PartitionKey != "PublicWatchList").ToList(); this.TestWatchListCustom = EnumerableUtils.PickRandom(AllWatchListsFromDBCustom); this.TestErcToken = await CreateTestErcToken(); }