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); }
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)); }
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); }
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); }