forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca51bc7
commit 381a986
Showing
19 changed files
with
184 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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 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 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
1 change: 1 addition & 0 deletions
1
experiments/Azure.Experiments/Azure.Experiments/Old/Compute/VirtualMachineObject.cs
This file contains 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
22 changes: 6 additions & 16 deletions
22
experiments/Azure.Experiments/Azure.Experiments/Old/Context.cs
This file contains 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 |
---|---|---|
@@ -1,24 +1,14 @@ | ||
using Microsoft.Azure.Management.Network; | ||
using Microsoft.Rest; | ||
using Microsoft.Azure.Experiments; | ||
using Microsoft.Azure.Management.Network; | ||
|
||
namespace Azure.Experiments | ||
{ | ||
public class Context | ||
public static class ContextEx | ||
{ | ||
public Context(ServiceClientCredentials credentials, string subscriptionId) | ||
{ | ||
Credentials = credentials; | ||
SubscriptionId = subscriptionId; | ||
} | ||
|
||
public ServiceClientCredentials Credentials { get; } | ||
|
||
public string SubscriptionId { get; } | ||
|
||
public NetworkManagementClient CreateNetwork() | ||
=> new NetworkManagementClient(Credentials) | ||
public static NetworkManagementClient CreateNetwork(this Context context) | ||
=> new NetworkManagementClient(context.Credentials) | ||
{ | ||
SubscriptionId = SubscriptionId | ||
SubscriptionId = context.SubscriptionId | ||
}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
experiments/Azure.Experiments/Azure.Experiments/Old/ResourceGroupObject.cs
This file contains 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 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 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 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 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,36 @@ | ||
using Microsoft.Azure.Management.Network; | ||
using Microsoft.Azure.Management.ResourceManager; | ||
using System; | ||
|
||
namespace Microsoft.Azure.Experiments.Tests | ||
{ | ||
class Client : IClient | ||
{ | ||
public Client(Context context) | ||
{ | ||
Context = context; | ||
} | ||
|
||
public Context Context { get; } | ||
|
||
public T GetClient<T>() | ||
where T: class, IDisposable | ||
{ | ||
if (typeof(T) == typeof(INetworkManagementClient)) | ||
{ | ||
return new NetworkManagementClient(Context.Credentials) | ||
{ | ||
SubscriptionId = Context.SubscriptionId | ||
} as T; | ||
} | ||
else if (typeof(T) == typeof(IResourceManagementClient)) | ||
{ | ||
return new ResourceManagementClient(Context.Credentials) | ||
{ | ||
SubscriptionId = Context.SubscriptionId | ||
} as T; | ||
} | ||
throw new Exception("unknown client type"); | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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 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,57 @@ | ||
using Microsoft.Azure.Experiments.ResourceManager; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.Azure.Experiments.Tests | ||
{ | ||
public class ResourceGroupTest | ||
{ | ||
[Fact] | ||
public void CreateConfigTest() | ||
{ | ||
var rg = ResourceGroupPolicy.CreateResourceGroupConfig("new"); | ||
var id = rg.GetId("12345").IdToString(); | ||
Assert.Equal("/subscriptions/12345/resourceGroups/new", id); | ||
} | ||
|
||
[Fact] | ||
public async Task GetAsyncTest() | ||
{ | ||
var rg = ResourceGroupPolicy.CreateResourceGroupConfig("new"); | ||
var client = new Client(Credentials.Get()); | ||
var state = await rg.GetAsync(client, new CancellationToken()); | ||
var location = state.GetLocation(rg); | ||
Assert.Null(location); | ||
} | ||
|
||
[Fact] | ||
public async Task CreateParameterTest() | ||
{ | ||
var rg = ResourceGroupPolicy.CreateResourceGroupConfig("new"); | ||
var client = new Client(Credentials.Get()); | ||
var state = await rg.GetAsync(client, new CancellationToken()); | ||
var location = state.GetLocation(rg); | ||
var parameters = rg.GetParameters(client.Context.SubscriptionId, "eastus"); | ||
var rgc = parameters.GetOrNull(rg); | ||
Assert.Equal("eastus", rgc.Location); | ||
} | ||
|
||
[Fact] | ||
public async Task CreateAsyncTest() | ||
{ | ||
var rg = ResourceGroupPolicy.CreateResourceGroupConfig("new1"); | ||
var client = new Client(Credentials.Get()); | ||
var state = await rg.GetAsync(client, new CancellationToken()); | ||
var location = state.GetLocation(rg); | ||
var parameters = rg.GetParameters(client.Context.SubscriptionId, "eastus"); | ||
var rgc = parameters.GetOrNull(rg); | ||
var createState = await rg.CreateOrUpdateAsync( | ||
client, state, parameters, new CancellationToken()); | ||
var rgcc = createState.GetOrNull(rg); | ||
Assert.Equal("eastus", rgcc.Location); | ||
Assert.Equal("new1", rgcc.Name); | ||
Assert.Equal(rg.GetId(client.Context.SubscriptionId).IdToString(), rgcc.Id); | ||
} | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.