コード例 #1
0
        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");
        }
コード例 #2
0
        public async Task CancelOperation()
        {
            string url      = ApiPaths.OPERATIONS_CANCEL_PATH + "/" + this.TestOperationCancel.Id;
            var    response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.POST);

            Assert.True(response.Status == HttpStatusCode.OK);

            OperationsEntity entity = await this.OperationsRepository.TryGetAsync(this.TestOperationCancel.Id) as OperationsEntity;

            OperationsEntity canceledEntity = await this.OperationsRepository.TryGetAsync("Canceled", this.TestOperationCancel.Id) as OperationsEntity;

            Assert.NotNull(canceledEntity);

            Assert.True(entity.StatusString == "Canceled");
        }
コード例 #3
0
        public async Task GetOperationById()
        {
            string url      = ApiPaths.OPERATIONS_BASE_PATH + "/" + this.TestOperation.Id;
            var    response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.GET);

            Assert.True(response.Status == HttpStatusCode.OK);

            OperationDTO     parsedResponse = JsonUtils.DeserializeJson <OperationDTO>(response.ResponseJson);
            OperationsEntity entity         = await this.OperationsRepository.TryGetAsync(parsedResponse.Id) as OperationsEntity;

            OperationContext entityContext = JsonUtils.DeserializeJson <OperationContext>(entity.Context);

            entityContext.ShouldBeEquivalentTo(parsedResponse.Context);
            Assert.True(entity.StatusString == parsedResponse.Status);
            Assert.True(entity.TypeString == parsedResponse.Type);
            Assert.True(entity.ClientId.ToString().ToLower() == parsedResponse.ClientId);
            Assert.True(entity.Created == parsedResponse.Created);
        }
コード例 #4
0
        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);
        }