Пример #1
0
        private async Task <BalanceV2> Create(Pkuid uid)
        {
            var data = new BalanceV2
            {
                userId  = uid.Guid,
                pk      = uid.PK,
                balance = new Dictionary <string, decimal>(),
                // balance = new Dictionary<string, decimal>{
                //     {D.CNY, 0},
                //     {D.USD, 0},
                //     {D.BTC, 0},
                //     {D.ETH, 0},
                // },
            };

            try
            {
                var res = await client.CreateDocumentAsync(BalanceV2._URI_COL, data, new RequestOptions
                {
                    PartitionKey = new PartitionKey(uid.PK)
                });

                return(data);
            }
            catch (DocumentClientException e)
            {
                Console.WriteLine(e.StatusCode);
                Console.WriteLine(e.Message);

                throw e;
            }
        }
Пример #2
0
        public async Task TestGetAccountBalance()
        {
            // Parameters for the API call
            var accountUid = GetAccountId();

            // Perform API call
            BalanceV2 result = null;

            try
            {
                result = await _controller.GetAccountBalanceAsync(accountUid);
            }
            catch (APIException) {};

            // Test response code
            Assert.AreEqual(200, HTTPCallBackHandler.Response.StatusCode,
                            "Status should be 200");

            // Test headers
            var headers = new Dictionary <string, string>();

            headers.Add("Content-Type", "application/json");

            Assert.IsTrue(TestHelper.AreHeadersProperSubsetOf(
                              headers, HTTPCallBackHandler.Response.Headers),
                          "Headers should match");
        }