Skip to content

Commit

Permalink
Add ResourceGroupOperations tests (#21893)
Browse files Browse the repository at this point in the history
* Change the accessbility to virtual for Resource.Id

* Add ResourceGroupOperations tests

* Remove parallelizable tag

* Update session records

Co-authored-by: m-nash <prognash@microsoft.com>
Co-authored-by: m-nash <prognash@gmail.com>
  • Loading branch information
3 people authored Jun 16, 2021
1 parent 1b2940f commit 2a3b968
Show file tree
Hide file tree
Showing 35 changed files with 29,427 additions and 10,911 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
Expand Down Expand Up @@ -76,6 +77,8 @@ public async Task Update()
Assert.AreEqual(rg1.Data.Location, rg2.Data.Location);
Assert.AreEqual(rg1.Data.ManagedBy, rg2.Data.ManagedBy);
Assert.AreEqual(rg1.Data.Tags, rg2.Data.Tags);

Assert.ThrowsAsync<ArgumentNullException>(async () => _ = await rg1.UpdateAsync(null));
}

[TestCase]
Expand All @@ -87,6 +90,12 @@ public async Task StartExportTemplate()
parameters.Resources.Add("*");
var expOp = await rg.StartExportTemplateAsync(parameters);
await expOp.WaitForCompletionAsync();

Assert.ThrowsAsync<ArgumentNullException>(async () =>
{
var expOp = await rg.StartExportTemplateAsync(null);
_ = await expOp.WaitForCompletionAsync();
});
}

[TestCase]
Expand All @@ -104,6 +113,9 @@ public async Task AddTag()
Assert.AreEqual(rg1.Data.Properties.ProvisioningState, rg2.Data.Properties.ProvisioningState);
Assert.AreEqual(rg1.Data.Location, rg2.Data.Location);
Assert.AreEqual(rg1.Data.ManagedBy, rg2.Data.ManagedBy);

Assert.ThrowsAsync<ArgumentException>(async () => _ = await rg1.AddTagAsync(null, "value"));
Assert.ThrowsAsync<ArgumentException>(async () => _ = await rg1.AddTagAsync(" ", "value"));
}

[TestCase]
Expand All @@ -123,6 +135,17 @@ public async Task StartAddTag()
Assert.AreEqual(rg1.Data.Properties.ProvisioningState, rg2.Data.Properties.ProvisioningState);
Assert.AreEqual(rg1.Data.Location, rg2.Data.Location);
Assert.AreEqual(rg1.Data.ManagedBy, rg2.Data.ManagedBy);

Assert.ThrowsAsync<ArgumentException>(async () =>
{
var addTagOp = await rg1.StartAddTagAsync(null, "value");
_ = await addTagOp.WaitForCompletionAsync();
});
Assert.ThrowsAsync<ArgumentException>(async () =>
{
var addTagOp = await rg1.StartAddTagAsync(" ", "value");
_ = await addTagOp.WaitForCompletionAsync();
});
}

[TestCase]
Expand All @@ -143,6 +166,8 @@ public async Task SetTags()
Assert.AreEqual(rg1.Data.Properties.ProvisioningState, rg2.Data.Properties.ProvisioningState);
Assert.AreEqual(rg1.Data.Location, rg2.Data.Location);
Assert.AreEqual(rg1.Data.ManagedBy, rg2.Data.ManagedBy);

Assert.ThrowsAsync<ArgumentNullException>(async () => _ = await rg1.SetTagsAsync(null));
}

[TestCase]
Expand All @@ -165,6 +190,12 @@ public async Task StartSetTags()
Assert.AreEqual(rg1.Data.Properties.ProvisioningState, rg2.Data.Properties.ProvisioningState);
Assert.AreEqual(rg1.Data.Location, rg2.Data.Location);
Assert.AreEqual(rg1.Data.ManagedBy, rg2.Data.ManagedBy);

Assert.ThrowsAsync<ArgumentNullException>(async () =>
{
var setTagOp = await rg1.StartSetTagsAsync(null);
_ = await setTagOp.WaitForCompletionAsync();
});
}

[TestCase]
Expand All @@ -190,6 +221,9 @@ public async Task RemoveTag()
Assert.AreEqual(rg1.Data.Properties.ProvisioningState, rg2.Data.Properties.ProvisioningState);
Assert.AreEqual(rg1.Data.Location, rg2.Data.Location);
Assert.AreEqual(rg1.Data.ManagedBy, rg2.Data.ManagedBy);

Assert.ThrowsAsync<ArgumentException>(async () => _ = await rg1.RemoveTagAsync(null));
Assert.ThrowsAsync<ArgumentException>(async () => _ = await rg1.RemoveTagAsync(" "));
}

[TestCase]
Expand Down Expand Up @@ -218,6 +252,17 @@ public async Task StartRemoveTag()
Assert.AreEqual(rg1.Data.Properties.ProvisioningState, rg2.Data.Properties.ProvisioningState);
Assert.AreEqual(rg1.Data.Location, rg2.Data.Location);
Assert.AreEqual(rg1.Data.ManagedBy, rg2.Data.ManagedBy);

Assert.ThrowsAsync<ArgumentException>(async () =>
{
var removeTagOp = await rg1.StartRemoveTagAsync(null);
_ = await removeTagOp.WaitForCompletionAsync();
});
Assert.ThrowsAsync<ArgumentException>(async () =>
{
var removeTagOp = await rg1.StartRemoveTagAsync(" ");
_ = await removeTagOp.WaitForCompletionAsync();
});
}

[TestCase]
Expand Down Expand Up @@ -257,6 +302,8 @@ public async Task MoveResources()
countRg2 = await GetResourceCountAsync(genericResources, rg2);
Assert.AreEqual(0, countRg1);
Assert.AreEqual(1, countRg2);

Assert.ThrowsAsync<ArgumentNullException>(async () => _ = await rg1.MoveResourcesAsync(null));
}

[TestCase]
Expand Down Expand Up @@ -286,6 +333,12 @@ public async Task StartMoveResources()
countRg2 = await GetResourceCountAsync(genericResources, rg2);
Assert.AreEqual(0, countRg1);
Assert.AreEqual(1, countRg2);

Assert.ThrowsAsync<ArgumentNullException>(async () =>
{
var moveOp = await rg1.StartMoveResourcesAsync(null);
_ = await moveOp.WaitForCompletionResponseAsync();
});
}

[TestCase]
Expand All @@ -302,6 +355,8 @@ public async Task ValidateMoveResources()
Response response = await rg1.ValidateMoveResourcesAsync(moveInfo);

Assert.AreEqual(204, response.Status);

Assert.ThrowsAsync<ArgumentNullException>(async () => _ = await rg1.ValidateMoveResourcesAsync(null));
}

[TestCase]
Expand All @@ -322,6 +377,12 @@ public async Task StartValidateMoveResources()
Response response = await validateOp.WaitForCompletionResponseAsync();

Assert.AreEqual(204, response.Status);

Assert.ThrowsAsync<ArgumentNullException>(async () =>
{
var moveOp = await rg1.StartValidateMoveResourcesAsync(null);
_ = await moveOp.WaitForCompletionResponseAsync();
});
}

[TestCase]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2a3b968

Please sign in to comment.