예제 #1
0
        public ProcessResult <Credit> QueryCredit()
        {
            ApiUser          apiUser   = new ApiUser("test", "test");
            CreditOperations creditOps = new CreditOperations();

            return(creditOps.Query(apiUser));
        }
        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);
        }
        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);
        }