Skip to content

Adding tests for profile cmdlets #1324

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 3 commits into from
Nov 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/CLU/CLUCoreCLR.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24711.0
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.Common", "Commands.Common\Commands.Common.xproj", "{5F567ACA-595E-436D-83DB-A21E08F82DF6}"
EndProject
Expand All @@ -11,6 +11,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.Common.Resources",
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Profile", "Microsoft.Azure.Commands.Profile\Microsoft.Azure.Commands.Profile.xproj", "{45B05B68-516F-4D74-897F-56D12894946C}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Profile.Test", "Microsoft.Azure.Commands.Profile.Test\Microsoft.Azure.Commands.Profile.Test.xproj", "{E267C25B-98EA-4872-9753-4F6B22F7CA24}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.ScenarioTests.ResourceManager.Common", "Commands.ScenarioTests.ResourceManager.Common\Commands.ScenarioTests.ResourceManager.Common.xproj", "{9D1F91E1-B319-4914-B09B-60070C5531C7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,6 +37,14 @@ Global
{45B05B68-516F-4D74-897F-56D12894946C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45B05B68-516F-4D74-897F-56D12894946C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45B05B68-516F-4D74-897F-56D12894946C}.Release|Any CPU.Build.0 = Release|Any CPU
{E267C25B-98EA-4872-9753-4F6B22F7CA24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E267C25B-98EA-4872-9753-4F6B22F7CA24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E267C25B-98EA-4872-9753-4F6B22F7CA24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E267C25B-98EA-4872-9753-4F6B22F7CA24}.Release|Any CPU.Build.0 = Release|Any CPU
{9D1F91E1-B319-4914-B09B-60070C5531C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D1F91E1-B319-4914-B09B-60070C5531C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D1F91E1-B319-4914-B09B-60070C5531C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D1F91E1-B319-4914-B09B-60070C5531C7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 16 additions & 2 deletions src/CLU/Commands.Common.Authentication/ClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,25 @@ public virtual TClient CreateArmClient<TClient>(AzureContext context, AzureEnvir

public virtual TClient CreateCustomArmClient<TClient>(params object[] parameters) where TClient : Microsoft.Rest.ServiceClient<TClient>
{
var handlers = new List<DelegatingHandler>();
var newParameters = new List<object>();
List<Type> types = new List<Type>();
foreach (object obj in parameters)
{
types.Add(obj.GetType());
if (obj is DelegatingHandler)
{
handlers.Add(obj as DelegatingHandler);
}
else
{
types.Add(obj.GetType());
newParameters.Add(obj);
}
}

types.Add(typeof (DelegatingHandler[]));
newParameters.Add(handlers.ToArray());


var constructor = typeof(TClient).GetConstructor(types.ToArray());

Expand All @@ -93,7 +107,7 @@ public virtual TClient CreateCustomArmClient<TClient>(params object[] parameters
throw new InvalidOperationException(string.Format(Resources.InvalidManagementClientType, typeof(TClient).Name));
}

TClient client = (TClient)constructor.Invoke(parameters);
TClient client = (TClient)constructor.Invoke(newParameters.ToArray());

foreach (ProductInfoHeaderValue userAgent in UserAgents)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Commands.Common.Authentication/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"System.Reflection.Extensions": "4.0.1-beta-23516",
"System.Reflection.Primitives": "4.0.1-beta-23516",
"System.Reflection.TypeExtensions": "4.1.0-beta-23516",
"System.Runtime": "4.0.20",
"System.Runtime": "4.0.21-beta-23516",
"System.Runtime.Extensions": "4.0.11-beta-23409",
"System.Runtime.Serialization.Json": "4.0.1-beta-23409",
"System.Runtime.Serialization.Primitives": "4.0.11-beta-23409",
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Commands.Common.Resources/AzureRmCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override void BeginProcessing()
var sessionProfile = GetSessionVariableValue<PSAzureProfile>(AzurePowerShell.ProfileVariable, null);
if (sessionProfile != null)
{
DefaultProfile = sessionProfile;
DefaultProfile = DefaultProfile?? sessionProfile;
}
base.BeginProcessing();
//TODO: Add back RP automatic registration
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Commands.Common.Resources/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"System.Reflection.Extensions": "4.0.1-beta-23516",
"System.Reflection.Primitives": "4.0.1-beta-23516",
"System.Reflection.TypeExtensions": "4.1.0-beta-23516",
"System.Runtime": "4.0.20",
"System.Runtime": "4.0.21-beta-23516",
"System.Runtime.Extensions": "4.0.11-beta-23409",
"System.Runtime.Serialization.Json": "4.0.1-beta-23409",
"System.Runtime.Serialization.Xml": "4.0.11-beta-23409",
Expand Down
14 changes: 8 additions & 6 deletions src/CLU/Commands.Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,20 @@ protected virtual bool IsErrorMetricEnabled
public AzurePSCmdlet()
{
_debugMessages = new ConcurrentQueue<string>();
// TODO: Instantiate ClientFactory and AuthenticationFactory
// remove
ClientFactory = new ClientFactory();
AuthenticationFactory = new AuthenticationFactory();
#if DEBUG
if (!TestMockSupport.RunningMocked)
{
#endif
DataStore = new DiskDataStore();
DataStore = DataStore ?? new DiskDataStore();
#if DEBUG
}
else
{
DataStore = new MemoryDataStore();
DataStore = DataStore ?? new MemoryDataStore();
}
#endif
AuthenticationFactory = AuthenticationFactory ?? new AuthenticationFactory(DataStore);
ClientFactory = ClientFactory?? new ClientFactory(DataStore, AuthenticationFactory);
}

protected virtual T GetSessionVariableValue<T>(string name, T defaultValue) where T : class
Expand Down Expand Up @@ -338,7 +336,11 @@ protected bool IsVerbose()
protected new void WriteObject(object sendToPipeline)
{
FlushDebugMessages();
#if DEBUG
CommandRuntime.WriteObject(sendToPipeline);
#else
base.WriteObject(sendToPipeline);
#endif
}

protected new void WriteObject(object sendToPipeline, bool enumerateCollection)
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Commands.Common/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"System.Reflection.Extensions": "4.0.1-beta-23516",
"System.Reflection.Primitives": "4.0.1-beta-23516",
"System.Reflection.TypeExtensions": "4.1.0-beta-23516",
"System.Runtime": "4.0.20",
"System.Runtime": "4.0.21-beta-23516",
"System.Runtime.Extensions": "4.0.11-beta-23409",
"System.Runtime.Serialization.Json": "4.0.1-beta-23409",
"System.Runtime.Serialization.Xml": "4.0.11-beta-23409",
Expand Down
Loading