Exemplo n.º 1
0
        public async Task GetVirtualMachinesPaginatedAsync_ExpectedClientCall()
        {
            IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>();

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

            var ops       = new VirtualMachineOperations <VirtualMachine>(client);
            var paginated = await ops.GetVirtualMachinesPaginatedAsync();

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