Exemple #1
0
        public async Task GetFirewallConfigAsync_ValidParameters_ExpectedResult()
        {
            IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>();

            client.GetAsync <FirewallConfig>("/ecloud/v1/firewalls/123/config").Returns(new FirewallConfig()
            {
                Config = "testconfig"
            });

            var ops    = new FirewallOperations <Firewall>(client);
            var config = await ops.GetFirewallConfigAsync(123);

            Assert.AreEqual("testconfig", config.Config);
        }
Exemple #2
0
        public async Task GetFirewallAsync_ValidParameters_ExpectedResult()
        {
            IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>();

            client.GetAsync <Firewall>("/ecloud/v1/firewalls/123").Returns(new Firewall()
            {
                ID = 123
            });

            var ops      = new FirewallOperations <Firewall>(client);
            var firewall = await ops.GetFirewallAsync(123);

            Assert.AreEqual(123, firewall.ID);
        }
Exemple #3
0
        public async Task GetFirewallsAsync_ExpectedResult()
        {
            IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>();

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

            var ops       = new FirewallOperations <Firewall>(client);
            var firewalls = await ops.GetFirewallsAsync();

            Assert.AreEqual(2, firewalls.Count);
        }
Exemple #4
0
        public async Task GetFirewallsPaginatedAsync_ExpectedClientCall()
        {
            IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>();

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

            var ops       = new FirewallOperations <Firewall>(client);
            var paginated = await ops.GetFirewallsPaginatedAsync();

            Assert.AreEqual(2, paginated.Items.Count);
        }
Exemple #5
0
        public async Task GetFirewallAsync_InvalidFirewallID_ThrowsUKFastClientValidationException()
        {
            var ops = new FirewallOperations <Firewall>(null);

            await Assert.ThrowsExceptionAsync <UKFastClientValidationException>(() => ops.GetFirewallAsync(0));
        }