public async Task <OperationCreateReturnDTO> CreateTestOperation() { string newId = Guid.NewGuid().ToString().ToLower(); string url = ApiPaths.OPERATIONS_TRANSFER_PATH + "/" + newId; OperationCreateDTO createDTO = new OperationCreateDTO() { Amount = Helpers.Random.Next(1, 10), AssetId = TestAssetId, SourceWalletId = TestWalletWithBalanceId, WalletId = TestWalletOperations.Id }; string createParam = JsonUtils.SerializeObject(createDTO); var response = await Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, createParam, Method.POST); if (response.Status != HttpStatusCode.Created) { return(null); } string parsedResponse = JsonUtils.DeserializeJson <string>(response.ResponseJson); OperationCreateReturnDTO returnDTO = new OperationCreateReturnDTO(createDTO) { Id = parsedResponse }; AddOneTimeCleanupAction(async() => await CancelTestOperation(returnDTO.Id)); return(returnDTO); }
public async Task CreateOperation() { OperationCreateReturnDTO createdDTO = await this.CreateTestOperation(); Assert.NotNull(createdDTO); OperationsEntity entity = await this.OperationsRepository.TryGetAsync(createdDTO.Id) as OperationsEntity; OperationsEntity createdEntity = await this.OperationsRepository.TryGetAsync("Created", createdDTO.Id) as OperationsEntity; Assert.NotNull(createdEntity); Assert.True(entity.StatusString == "Created"); Assert.True(entity.TypeString == "Transfer"); }
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); }