Exemple #1
0
        public async Task UpdateForwardingRule()
        {
            // ARRANGE
            var forwardingRuleData = new ForwardingRuleData();

            forwardingRuleData.DomainName = "test.com.";
            forwardingRuleData.TargetDnsServers.Add(new TargetDnsServer()
            {
                IPAddress = "10.0.0.3",
            });

            var forwardingRuleName    = Recording.GenerateAssetName("forwardingRule-");
            var createdForwardingRule = await dnsForwardingRuleset.GetForwardingRules().CreateOrUpdateAsync(WaitUntil.Completed, forwardingRuleName, forwardingRuleData);

            var newTagKey   = Recording.GenerateAlphaNumericId("tagKey");
            var newTagValue = Recording.GenerateAlphaNumericId("tagValue");

            var patchableForwardingRuleData = new PatchableForwardingRuleData();

            patchableForwardingRuleData.Metadata.Add(newTagKey, newTagValue);

            // ACT
            var patchedForwardingRule = await createdForwardingRule.Value.UpdateAsync(patchableForwardingRuleData);

            // ASSERT
            CollectionAssert.AreEquivalent(patchedForwardingRule.Value.Data.Metadata, patchableForwardingRuleData.Metadata);
        }
Exemple #2
0
        internal static ForwardingRuleListResult DeserializeForwardingRuleListResult(JsonElement element)
        {
            Optional <IReadOnlyList <ForwardingRuleData> > value = default;
            Optional <string> nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ForwardingRuleData> array = new List <ForwardingRuleData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ForwardingRuleData.DeserializeForwardingRuleData(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new ForwardingRuleListResult(Optional.ToList(value), nextLink.Value));
        }
Exemple #3
0
        public async Task CreateForwardingRule()
        {
            // ARRANGE
            var forwardingRuleData = new ForwardingRuleData();

            forwardingRuleData.DomainName = "test.com.";
            forwardingRuleData.TargetDnsServers.Add(new TargetDnsServer()
            {
                IPAddress = "10.0.0.3",
            });

            var forwardingRuleName = Recording.GenerateAssetName("forwardingRule-");

            // ACT
            var createdForwardingRule = await dnsForwardingRuleset.GetForwardingRules().CreateOrUpdateAsync(WaitUntil.Completed, forwardingRuleName, forwardingRuleData);

            // ASSERT
            Assert.AreEqual(createdForwardingRule.Value.Data.ProvisioningState, ProvisioningState.Succeeded);
        }
Exemple #4
0
        public async Task RemoveForwardingRule()
        {
            // ARRANGE
            var forwardingRuleData = new ForwardingRuleData();

            forwardingRuleData.DomainName = "test.com.";
            forwardingRuleData.TargetDnsServers.Add(new TargetDnsServer()
            {
                IPAddress = "10.0.0.3",
            });

            var forwardingRuleName    = Recording.GenerateAssetName("forwardingRule-");
            var createdForwardingRule = await dnsForwardingRuleset.GetForwardingRules().CreateOrUpdateAsync(WaitUntil.Completed, forwardingRuleName, forwardingRuleData);

            // ACT
            await createdForwardingRule.Value.DeleteAsync(WaitUntil.Completed);

            // ASSERT
            var getForwardingRule = await dnsForwardingRuleset.GetForwardingRules().ExistsAsync(forwardingRuleName);

            Assert.AreEqual(getForwardingRule.Value, false);
        }