Skip to content

Commit fef5c28

Browse files
author
Hovsep
committed
Merge pull request Azure#1324 from markcowl/clunew50
Adding tests for profile cmdlets
2 parents 520e621 + ec2ac95 commit fef5c28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+12929
-23
lines changed

src/CLU/CLUCoreCLR.sln

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.24711.0
4+
VisualStudioVersion = 14.0.23107.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.Common", "Commands.Common\Commands.Common.xproj", "{5F567ACA-595E-436D-83DB-A21E08F82DF6}"
77
EndProject
@@ -11,6 +11,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.Common.Resources",
1111
EndProject
1212
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Profile", "Microsoft.Azure.Commands.Profile\Microsoft.Azure.Commands.Profile.xproj", "{45B05B68-516F-4D74-897F-56D12894946C}"
1313
EndProject
14+
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}"
15+
EndProject
16+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.ScenarioTests.ResourceManager.Common", "Commands.ScenarioTests.ResourceManager.Common\Commands.ScenarioTests.ResourceManager.Common.xproj", "{9D1F91E1-B319-4914-B09B-60070C5531C7}"
17+
EndProject
1418
Global
1519
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1620
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +37,14 @@ Global
3337
{45B05B68-516F-4D74-897F-56D12894946C}.Debug|Any CPU.Build.0 = Debug|Any CPU
3438
{45B05B68-516F-4D74-897F-56D12894946C}.Release|Any CPU.ActiveCfg = Release|Any CPU
3539
{45B05B68-516F-4D74-897F-56D12894946C}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{E267C25B-98EA-4872-9753-4F6B22F7CA24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41+
{E267C25B-98EA-4872-9753-4F6B22F7CA24}.Debug|Any CPU.Build.0 = Debug|Any CPU
42+
{E267C25B-98EA-4872-9753-4F6B22F7CA24}.Release|Any CPU.ActiveCfg = Release|Any CPU
43+
{E267C25B-98EA-4872-9753-4F6B22F7CA24}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{9D1F91E1-B319-4914-B09B-60070C5531C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{9D1F91E1-B319-4914-B09B-60070C5531C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{9D1F91E1-B319-4914-B09B-60070C5531C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
47+
{9D1F91E1-B319-4914-B09B-60070C5531C7}.Release|Any CPU.Build.0 = Release|Any CPU
3648
EndGlobalSection
3749
GlobalSection(SolutionProperties) = preSolution
3850
HideSolutionNode = FALSE

src/CLU/Commands.Common.Authentication/ClientFactory.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,25 @@ public virtual TClient CreateArmClient<TClient>(AzureContext context, AzureEnvir
8080

8181
public virtual TClient CreateCustomArmClient<TClient>(params object[] parameters) where TClient : Microsoft.Rest.ServiceClient<TClient>
8282
{
83+
var handlers = new List<DelegatingHandler>();
84+
var newParameters = new List<object>();
8385
List<Type> types = new List<Type>();
8486
foreach (object obj in parameters)
8587
{
86-
types.Add(obj.GetType());
88+
if (obj is DelegatingHandler)
89+
{
90+
handlers.Add(obj as DelegatingHandler);
91+
}
92+
else
93+
{
94+
types.Add(obj.GetType());
95+
newParameters.Add(obj);
96+
}
8797
}
98+
99+
types.Add(typeof (DelegatingHandler[]));
100+
newParameters.Add(handlers.ToArray());
101+
88102

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

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

96-
TClient client = (TClient)constructor.Invoke(parameters);
110+
TClient client = (TClient)constructor.Invoke(newParameters.ToArray());
97111

98112
foreach (ProductInfoHeaderValue userAgent in UserAgents)
99113
{

src/CLU/Commands.Common.Authentication/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"System.Reflection.Extensions": "4.0.1-beta-23516",
3232
"System.Reflection.Primitives": "4.0.1-beta-23516",
3333
"System.Reflection.TypeExtensions": "4.1.0-beta-23516",
34-
"System.Runtime": "4.0.20",
34+
"System.Runtime": "4.0.21-beta-23516",
3535
"System.Runtime.Extensions": "4.0.11-beta-23409",
3636
"System.Runtime.Serialization.Json": "4.0.1-beta-23409",
3737
"System.Runtime.Serialization.Primitives": "4.0.11-beta-23409",

src/CLU/Commands.Common.Resources/AzureRmCmdlet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected override void BeginProcessing()
6363
var sessionProfile = GetSessionVariableValue<PSAzureProfile>(AzurePowerShell.ProfileVariable, null);
6464
if (sessionProfile != null)
6565
{
66-
DefaultProfile = sessionProfile;
66+
DefaultProfile = DefaultProfile?? sessionProfile;
6767
}
6868
base.BeginProcessing();
6969
//TODO: Add back RP automatic registration

src/CLU/Commands.Common.Resources/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"System.Reflection.Extensions": "4.0.1-beta-23516",
3333
"System.Reflection.Primitives": "4.0.1-beta-23516",
3434
"System.Reflection.TypeExtensions": "4.1.0-beta-23516",
35-
"System.Runtime": "4.0.20",
35+
"System.Runtime": "4.0.21-beta-23516",
3636
"System.Runtime.Extensions": "4.0.11-beta-23409",
3737
"System.Runtime.Serialization.Json": "4.0.1-beta-23409",
3838
"System.Runtime.Serialization.Xml": "4.0.11-beta-23409",

src/CLU/Commands.Common/AzurePSCmdlet.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,20 @@ protected virtual bool IsErrorMetricEnabled
8484
public AzurePSCmdlet()
8585
{
8686
_debugMessages = new ConcurrentQueue<string>();
87-
// TODO: Instantiate ClientFactory and AuthenticationFactory
88-
// remove
89-
ClientFactory = new ClientFactory();
90-
AuthenticationFactory = new AuthenticationFactory();
9187
#if DEBUG
9288
if (!TestMockSupport.RunningMocked)
9389
{
9490
#endif
95-
DataStore = new DiskDataStore();
91+
DataStore = DataStore ?? new DiskDataStore();
9692
#if DEBUG
9793
}
9894
else
9995
{
100-
DataStore = new MemoryDataStore();
96+
DataStore = DataStore ?? new MemoryDataStore();
10197
}
10298
#endif
99+
AuthenticationFactory = AuthenticationFactory ?? new AuthenticationFactory(DataStore);
100+
ClientFactory = ClientFactory?? new ClientFactory(DataStore, AuthenticationFactory);
103101
}
104102

105103
protected virtual T GetSessionVariableValue<T>(string name, T defaultValue) where T : class
@@ -338,7 +336,11 @@ protected bool IsVerbose()
338336
protected new void WriteObject(object sendToPipeline)
339337
{
340338
FlushDebugMessages();
339+
#if DEBUG
340+
CommandRuntime.WriteObject(sendToPipeline);
341+
#else
341342
base.WriteObject(sendToPipeline);
343+
#endif
342344
}
343345

344346
protected new void WriteObject(object sendToPipeline, bool enumerateCollection)

src/CLU/Commands.Common/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"System.Reflection.Extensions": "4.0.1-beta-23516",
3232
"System.Reflection.Primitives": "4.0.1-beta-23516",
3333
"System.Reflection.TypeExtensions": "4.1.0-beta-23516",
34-
"System.Runtime": "4.0.20",
34+
"System.Runtime": "4.0.21-beta-23516",
3535
"System.Runtime.Extensions": "4.0.11-beta-23409",
3636
"System.Runtime.Serialization.Json": "4.0.1-beta-23409",
3737
"System.Runtime.Serialization.Xml": "4.0.11-beta-23409",

0 commit comments

Comments
 (0)