Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30309.148
# Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1
Project("{D5E9998A-C0D9-4CF4-9183-C37B152E4E68}") = "Azure.ResourceManager.HealthBot", "src\Azure.ResourceManager.HealthBot.csproj", "{ACA94220-0BF9-4B53-8F79-D96A0172D032}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.HealthBot", "src\Azure.ResourceManager.HealthBot.csproj", "{ACA94220-0BF9-4B53-8F79-D96A0172D032}"
EndProject
Project("{D5E9998A-C0D9-4CF4-9183-C37B152E4E68}") = "Azure.ResourceManager.HealthBot.Tests", "tests\Azure.ResourceManager.HealthBot.Tests.csproj", "{969125CD-196D-43AF-9FBD-6FAF4E7D1E58}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.HealthBot.Tests", "tests\Azure.ResourceManager.HealthBot.Tests.csproj", "{969125CD-196D-43AF-9FBD-6FAF4E7D1E58}"
EndProject
Project("{D5E9998A-C0D9-4CF4-9183-C37B152E4E68}") = "Azure.ResourceManager.HealthBot.Samples", "samples\Azure.ResourceManager.HealthBot.Samples.csproj", "{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.HealthBot.Samples", "samples\Azure.ResourceManager.HealthBot.Samples.csproj", "{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}"
EndProject
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D87D4EC-5A6B-4D0D-B8A6-855128ACF273}
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -49,5 +43,23 @@ Global
{969125CD-196D-43AF-9FBD-6FAF4E7D1E58}.Release|x64.Build.0 = Release|Any CPU
{969125CD-196D-43AF-9FBD-6FAF4E7D1E58}.Release|x86.ActiveCfg = Release|Any CPU
{969125CD-196D-43AF-9FBD-6FAF4E7D1E58}.Release|x86.Build.0 = Release|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Debug|x64.ActiveCfg = Debug|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Debug|x64.Build.0 = Debug|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Debug|x86.ActiveCfg = Debug|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Debug|x86.Build.0 = Debug|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Release|Any CPU.Build.0 = Release|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Release|x64.ActiveCfg = Release|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Release|x64.Build.0 = Release|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Release|x86.ActiveCfg = Release|Any CPU
{9F01AA5C-758A-4C3A-B2D7-53C7A5EB843B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D87D4EC-5A6B-4D0D-B8A6-855128ACF273}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/healthbot/Azure.ResourceManager.HealthBot",
"Tag": ""
"Tag": "net/healthbot/Azure.ResourceManager.HealthBot_4ebbb344b7"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace Azure.ResourceManager.HealthBot.Tests
public class HealthBotManagementTestBase : ManagementRecordedTestBase<HealthBotManagementTestEnvironment>
{
protected ArmClient Client { get; private set; }

protected AzureLocation DefaultLocation => AzureLocation.EastUS;
protected string groupName;
protected SubscriptionResource DefaultSubscription { get; private set; }
protected HealthBotManagementTestBase(bool isAsync, RecordedTestMode mode)
: base(isAsync, mode)
{
Expand All @@ -25,17 +27,37 @@ protected HealthBotManagementTestBase(bool isAsync)
}

[SetUp]
public void CreateCommonClient()
public async Task CreateCommonClient()
{
Client = GetArmClient();
DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false);
}

protected async Task<ResourceGroupResource> CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location)
protected async Task<ResourceGroupResource> CreateResourceGroupAsync()
{
string rgName = Recording.GenerateAssetName(rgNamePrefix);
ResourceGroupData input = new ResourceGroupData(location);
var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input);
return lro.Value;
var resourceGroupName = Recording.GenerateAssetName("testRG-");
var rgOp = await DefaultSubscription.GetResourceGroups().CreateOrUpdateAsync(
WaitUntil.Completed,
resourceGroupName,
new ResourceGroupData(DefaultLocation)
{
Tags =
{
{ "test", "env" }
}
});
if (Mode == RecordedTestMode.Playback)
{
groupName = resourceGroupName;
}
else
{
using (Recording.DisableRecording())
{
groupName = rgOp.Value.Data.Name;
}
}
return rgOp.Value;
}
}
}
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);
}
}
}