コード例 #1
0
ファイル: Test.cs プロジェクト: nirvanasms/api-library
        public ProcessResult <Credit> QueryCredit()
        {
            ApiUser          apiUser   = new ApiUser("test", "test");
            CreditOperations creditOps = new CreditOperations();

            return(creditOps.Query(apiUser));
        }
コード例 #2
0
        public async Task GetCreditsAsync_ExpectedResult()
        {
            IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>();

            client.GetAllAsync(Arg.Any <UKFastClient.GetPaginatedAsyncFunc <Credit> >(), null).Returns(Task.Run <IList <Credit> >(() =>
            {
                return(new List <Credit>()
                {
                    new Credit(),
                    new Credit()
                });
            }));

            var ops     = new CreditOperations <Credit>(client);
            var credits = await ops.GetCreditsAsync();

            Assert.AreEqual(2, credits.Count);
        }
コード例 #3
0
        public async Task GetCreditsPaginatedAsync_ExpectedClientCall()
        {
            IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>();

            client.GetPaginatedAsync <Credit>("/ecloud/v1/credits").Returns(Task.Run(() =>
            {
                return(new Paginated <Credit>(client, "/ecloud/v1/credits", null, new Response.ClientResponse <System.Collections.Generic.IList <Credit> >()
                {
                    Body = new Response.ClientResponseBody <System.Collections.Generic.IList <Credit> >()
                    {
                        Data = new List <Credit>()
                        {
                            new Credit(),
                            new Credit()
                        }
                    }
                }));
            }));

            var ops       = new CreditOperations <Credit>(client);
            var paginated = await ops.GetCreditsPaginatedAsync();

            Assert.AreEqual(2, paginated.Items.Count);
        }