-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Health bot tests #35979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Health bot tests #35979
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
edc3ec8
update
mcgallan 46f4cd2
Merge remote-tracking branch 'upstream/main' into HealthBotTests
mcgallan 0f368af
update
mcgallan 6ea8a83
Update HealthBotTests.cs
mcgallan b612dcb
Merge remote-tracking branch 'upstream/main' into HealthBotTests
mcgallan dc35f9c
Merge remote-tracking branch 'upstream/main' into HealthBotTests
mcgallan cae32cb
Update HealthBotTests.cs
mcgallan 9fe6c5d
Merge remote-tracking branch 'upstream/main' into HealthBotTests
mcgallan c2ddac8
Update HealthBotTests.cs
mcgallan a03e654
update
mcgallan 77939d7
update
mcgallan 3801014
Merge branch 'main' into HealthBotTests
mcgallan 93d6896
update
mcgallan ffb9a59
update
mcgallan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
sdk/healthbot/Azure.ResourceManager.HealthBot/tests/TestCase/HealthBotTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Threading.Tasks; | ||
| using Azure.Core; | ||
| using Azure.Core.TestFramework; | ||
| using Azure.ResourceManager.HealthBot.Models; | ||
| using Azure.ResourceManager.Models; | ||
| using Azure.ResourceManager.Resources; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Azure.ResourceManager.HealthBot.Tests.TestCase | ||
| { | ||
| public class HealthBotTests : HealthBotManagementTestBase | ||
| { | ||
| public HealthBotTests(bool isAsync) | ||
| : base(isAsync)//, RecordedTestMode.Record) | ||
| { | ||
| } | ||
|
|
||
| public async Task<HealthBotCollection> GetHealthBotCollection() | ||
| { | ||
| var group = await CreateResourceGroupAsync(); | ||
| var collection = group.GetHealthBots(); | ||
| return collection; | ||
| } | ||
|
|
||
| public HealthBotData GetHealthBotData() | ||
| { | ||
| var data = new HealthBotData(DefaultLocation, new HealthBotSku(HealthBotSkuName.F0)); | ||
| return data; | ||
| } | ||
| public static void AssertData(HealthBotData data1, HealthBotData data2) | ||
| { | ||
| Assert.AreEqual(data1.Name, data2.Name); | ||
| Assert.AreEqual(data1.Id, data2.Id); | ||
| Assert.AreEqual(data1.Location, data2.Location); | ||
| } | ||
|
|
||
| [RecordedTest] | ||
| public async Task HealthBotApiTests() | ||
| { | ||
| //1.CreateOrUpdate | ||
| var collection = await GetHealthBotCollection(); | ||
| var name = Recording.GenerateAssetName("healthbot-"); | ||
| var name2 = Recording.GenerateAssetName("healthbot-"); | ||
| var name3 = Recording.GenerateAssetName("healthbot-"); | ||
| var input = GetHealthBotData(); | ||
| var lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, input); | ||
| HealthBotResource healthBot1 = lro.Value; | ||
| Assert.AreEqual(name, healthBot1.Data.Name); | ||
| //2.Get | ||
| HealthBotResource HealthBot2 = await collection.GetAsync(name); | ||
| AssertData(healthBot1.Data, HealthBot2.Data); | ||
| //3.GetAll | ||
| _ = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, input); | ||
| _ = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name2, input); | ||
| _ = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name3, input); | ||
| int count = 0; | ||
| await foreach (var num in collection.GetAllAsync()) | ||
| { | ||
| count++; | ||
| } | ||
| Assert.GreaterOrEqual(count, 3); | ||
| //.ListBotsBySubscription | ||
| await foreach (var num in DefaultSubscription.GetHealthBotsAsync()) | ||
| { | ||
| count++; | ||
| } | ||
| Assert.GreaterOrEqual(count, 6); | ||
| //4Exists | ||
| Assert.IsTrue(await collection.ExistsAsync(name)); | ||
| Assert.IsFalse(await collection.ExistsAsync(name + "1")); | ||
|
|
||
| Assert.ThrowsAsync<ArgumentNullException>(async () => _ = await collection.ExistsAsync(null)); | ||
| //Resource | ||
| //5.Get | ||
| HealthBotResource healthBot3 = await healthBot1.GetAsync(); | ||
|
|
||
| AssertData(healthBot1.Data, healthBot3.Data); | ||
| //6.Update | ||
| HealthBotResource healthBot5 = Client.GetHealthBotResource(new ResourceIdentifier("/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c/resourceGroups/deleteme0713/providers/Microsoft.HealthBot/healthBots/bottest")); | ||
| HealthBotPatch patch = new HealthBotPatch() | ||
| { | ||
| Tags = | ||
| { | ||
| { "updateKey", "updateValue" } | ||
| }, | ||
| //Sku = new HealthBotSku(HealthBotSkuName.S1) | ||
| }; | ||
| HealthBotResource result = await healthBot5.UpdateAsync(patch); | ||
| //7.Delete | ||
| await healthBot1.DeleteAsync(WaitUntil.Completed); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.