Skip to content

Commit 9ee382e

Browse files
author
Hao Chen
committed
Fixed failing tests
1 parent 1e15710 commit 9ee382e

14 files changed

+53
-5
lines changed

src/CLU/Commands.Common/AzurePSCmdlet.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,7 @@ protected bool IsVerbose()
359359
protected new void WriteObject(object sendToPipeline, bool enumerateCollection)
360360
{
361361
FlushDebugMessages();
362-
#if DEBUG
363-
CommandRuntime.WriteObject(sendToPipeline, enumerateCollection);
364-
#else
365362
base.WriteObject(sendToPipeline, enumerateCollection);
366-
#endif
367363
}
368364

369365
protected new void WriteVerbose(string text)

src/CLU/Microsoft.Azure.Commands.Resources.Test/Features/GetAzureProviderFeatureCmdletTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.Resources.Test
1616
{
1717
using Commands.Test.Utilities.Common;
18+
using Common.Test.Mocks;
1819
using Microsoft.Azure.Commands.Resources.Models.ProviderFeatures;
1920
using Microsoft.Azure.Commands.Resources.ProviderFeatures;
2021
using Microsoft.Azure.Management.Resources;
@@ -45,6 +46,7 @@ public class GetAzureProviderFeatureCmdletTests : RMTestBase
4546
/// A mock of the command runtime
4647
/// </summary>
4748
private readonly Mock<ICommandRuntime> commandRuntimeMock;
49+
private MockCommandRuntime mockRuntime;
4850

4951
/// <summary>
5052
/// A mock of the client
@@ -73,8 +75,9 @@ public GetAzureProviderFeatureCmdletTests()
7375
FeaturesManagementClient = featureClient.Object
7476
}
7577
};
76-
//System.Reflection.TypeExtensions.GetProperty(cmdlet.GetType(), "CommandRuntime").SetValue(cmdlet, commandRuntimeMock.Object);
7778
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
79+
mockRuntime = new MockCommandRuntime();
80+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
7881
}
7982

8083
/// <summary>

src/CLU/Microsoft.Azure.Commands.Resources.Test/Features/RegisterProviderFeatureCmdletTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.Resources.Test
1616
{
1717
using Commands.Test.Utilities.Common;
18+
using Common.Test.Mocks;
1819
using Microsoft.Azure.Commands.Resources.Models.ProviderFeatures;
1920
using Microsoft.Azure.Commands.Resources.ProviderFeatures;
2021
using Microsoft.Azure.Management.Resources;
@@ -49,6 +50,7 @@ public class RegisterAzureProviderFeatureCmdletTests : RMTestBase
4950
/// A mock of the command runtime
5051
/// </summary>
5152
private readonly Mock<ICommandRuntime> commandRuntimeMock;
53+
private MockCommandRuntime mockRuntime;
5254

5355
/// <summary>
5456
/// Initializes a new instance of the <see cref="GetAzureProviderFeatureCmdletTests"/> class.
@@ -77,6 +79,8 @@ public RegisterAzureProviderFeatureCmdletTests()
7779
}
7880
};
7981
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
82+
mockRuntime = new MockCommandRuntime();
83+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
8084
}
8185

8286
/// <summary>

src/CLU/Microsoft.Azure.Commands.Resources.Test/Providers/GetAzureProviderCmdletTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.Resources.Test
1616
{
1717
using Commands.Test.Utilities.Common;
18+
using Common.Test.Mocks;
1819
using Microsoft.Azure.Commands.Providers;
1920
using Microsoft.Azure.Commands.Resources.Models;
2021
using Microsoft.Azure.Management.Resources;
@@ -45,6 +46,7 @@ public class GetAzureProviderCmdletTests : RMTestBase
4546
/// A mock of the command runtime
4647
/// </summary>
4748
private readonly Mock<ICommandRuntime> commandRuntimeMock;
49+
private MockCommandRuntime mockRuntime;
4850

4951
/// <summary>
5052
/// A mock of the client
@@ -73,6 +75,8 @@ public GetAzureProviderCmdletTests()
7375
}
7476
};
7577
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
78+
mockRuntime = new MockCommandRuntime();
79+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
7680
}
7781

7882
/// <summary>

src/CLU/Microsoft.Azure.Commands.Resources.Test/Providers/RegisterResourceProviderCmdletTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.Resources.Test
1616
{
1717
using Commands.Test.Utilities.Common;
18+
using Common.Test.Mocks;
1819
using Microsoft.Azure.Commands.Resources.Models;
1920
using Microsoft.Azure.Management.Resources;
2021
using Microsoft.Azure.Management.Resources.Models;
@@ -48,6 +49,7 @@ public class RegisterAzureProviderCmdletTests : RMTestBase
4849
/// A mock of the command runtime
4950
/// </summary>
5051
private readonly Mock<ICommandRuntime> commandRuntimeMock;
52+
private MockCommandRuntime mockRuntime;
5153

5254
/// <summary>
5355
/// Initializes a new instance of the <see cref="RegisterAzureProviderCmdletTests"/> class.
@@ -77,6 +79,8 @@ public RegisterAzureProviderCmdletTests()
7779
}
7880
};
7981
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
82+
mockRuntime = new MockCommandRuntime();
83+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
8084
}
8185

8286
/// <summary>

src/CLU/Microsoft.Azure.Commands.Resources.Test/Providers/UnregisterResourceProviderCmdletTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.Resources.Test
1616
{
1717
using Commands.Test.Utilities.Common;
18+
using Common.Test.Mocks;
1819
using Microsoft.Azure.Commands.Resources.Models;
1920
using Microsoft.Azure.Management.Resources;
2021
using Microsoft.Azure.Management.Resources.Models;
@@ -48,6 +49,7 @@ public class UnregisterAzureProviderCmdletTests : RMTestBase
4849
/// A mock of the command runtime
4950
/// </summary>
5051
private readonly Mock<ICommandRuntime> commandRuntimeMock;
52+
private MockCommandRuntime mockRuntime;
5153

5254
/// <summary>
5355
/// Initializes a new instance of the <see cref="GetAzureProviderCmdletTests"/> class.
@@ -77,6 +79,8 @@ public UnregisterAzureProviderCmdletTests()
7779
}
7880
};
7981
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
82+
mockRuntime = new MockCommandRuntime();
83+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
8084
}
8185

8286
/// <summary>

src/CLU/Microsoft.Azure.Commands.Resources.Test/ResourceGroupDeployments/GetAzureResourceGroupDeploymentCommandTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Test.Mocks;
1516
using Microsoft.Azure.Commands.Resources.Models;
1617
using Microsoft.Azure.Commands.ScenarioTest;
1718
using Microsoft.Azure.Commands.Test.Utilities.Common;
@@ -30,6 +31,7 @@ public class GetAzureResourceGroupDeploymentCommandTests : RMTestBase
3031
private Mock<ResourcesClient> resourcesClientMock;
3132

3233
private Mock<ICommandRuntime> commandRuntimeMock;
34+
private MockCommandRuntime mockRuntime;
3335

3436
private string resourceGroupName = "myResourceGroup";
3537

@@ -45,6 +47,8 @@ public GetAzureResourceGroupDeploymentCommandTests()
4547
ResourcesClient = resourcesClientMock.Object
4648
};
4749
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
50+
mockRuntime = new MockCommandRuntime();
51+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
4852
}
4953

5054
[Fact]

src/CLU/Microsoft.Azure.Commands.Resources.Test/ResourceGroupDeployments/NewAzureResourceGroupDeploymentCommandTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Test.Mocks;
1516
using Microsoft.Azure.Commands.Resources.Models;
1617
using Microsoft.Azure.Commands.ScenarioTest;
1718
using Microsoft.Azure.Commands.Test.Utilities.Common;
@@ -31,6 +32,7 @@ public class NewAzureResourceGroupDeploymentCommandTests : RMTestBase
3132
private Mock<ResourcesClient> resourcesClientMock;
3233

3334
private Mock<ICommandRuntime> commandRuntimeMock;
35+
private MockCommandRuntime mockRuntime;
3436

3537
private string resourceGroupName = "myResourceGroup";
3638

@@ -50,6 +52,8 @@ public NewAzureResourceGroupDeploymentCommandTests()
5052
ResourcesClient = resourcesClientMock.Object
5153
};
5254
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
55+
mockRuntime = new MockCommandRuntime();
56+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
5357
}
5458

5559
[Fact]

src/CLU/Microsoft.Azure.Commands.Resources.Test/ResourceGroupDeployments/RemoveAzureResourceGroupDeploymentCommandTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Test.Mocks;
1516
using Microsoft.Azure.Commands.Resources.Models;
1617
using Microsoft.Azure.Commands.Resources.ResourceGroups;
1718
using Microsoft.Azure.Commands.ScenarioTest;
@@ -28,6 +29,7 @@ public class RemoveAzureResourceGroupDeploymentCommandTests
2829
private Mock<ResourcesClient> resourcesClientMock;
2930

3031
private Mock<ICommandRuntime> commandRuntimeMock;
32+
private MockCommandRuntime mockRuntime;
3133

3234
private string resourceGroupName = "myResourceGroup";
3335

@@ -43,6 +45,8 @@ public RemoveAzureResourceGroupDeploymentCommandTests()
4345
ResourcesClient = resourcesClientMock.Object
4446
};
4547
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
48+
mockRuntime = new MockCommandRuntime();
49+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
4650
}
4751

4852
[Fact]

src/CLU/Microsoft.Azure.Commands.Resources.Test/ResourceGroupDeployments/StopAzureResourceGroupDeploymentCommandTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Test.Mocks;
1516
using Microsoft.Azure.Commands.Resources.Models;
1617
using Microsoft.Azure.Commands.Resources.ResourceGroups;
1718
using Microsoft.Azure.Commands.ScenarioTest;
@@ -28,6 +29,7 @@ public class StopAzureResourceGroupDeploymentCommandTests
2829
private Mock<ResourcesClient> resourcesClientMock;
2930

3031
private Mock<ICommandRuntime> commandRuntimeMock;
32+
private MockCommandRuntime mockRuntime;
3133

3234
private string resourceGroupName = "myResourceGroup";
3335

@@ -41,6 +43,8 @@ public StopAzureResourceGroupDeploymentCommandTests()
4143
ResourcesClient = resourcesClientMock.Object
4244
};
4345
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
46+
mockRuntime = new MockCommandRuntime();
47+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
4448
}
4549

4650
[Fact]

src/CLU/Microsoft.Azure.Commands.Resources.Test/ResourceGroupDeployments/TestAzureResourceGroupDeploymentCommandTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Test.Mocks;
1516
using Microsoft.Azure.Commands.Resources.Models;
1617
using Microsoft.Azure.Commands.Resources.ResourceGroupDeployments;
1718
using Microsoft.Azure.Commands.ScenarioTest;
@@ -30,6 +31,7 @@ public class TestAzureResourceGroupDeploymentCommandTests
3031
private Mock<ResourcesClient> resourcesClientMock;
3132

3233
private Mock<ICommandRuntime> commandRuntimeMock;
34+
private MockCommandRuntime mockRuntime;
3335

3436
private string resourceGroupName = "myResourceGroup";
3537

@@ -45,6 +47,8 @@ public TestAzureResourceGroupDeploymentCommandTests()
4547
ResourcesClient = resourcesClientMock.Object
4648
};
4749
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
50+
mockRuntime = new MockCommandRuntime();
51+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
4852
}
4953

5054
[Fact]

src/CLU/Microsoft.Azure.Commands.Resources.Test/ResourceGroups/GetAzureResourceGroupCommandTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Test.Mocks;
1516
using Microsoft.Azure.Commands.Resources.Models;
1617
using Microsoft.Azure.Commands.ScenarioTest;
1718
using Microsoft.Azure.Commands.Test.Utilities.Common;
@@ -30,6 +31,8 @@ public class GetAzureResourceGroupCommandTests : RMTestBase
3031

3132
private Mock<ICommandRuntime> commandRuntimeMock;
3233

34+
private MockCommandRuntime mockRuntime;
35+
3336
private string resourceGroupName = "myResourceGroup";
3437
private string resourceGroupId = "/subscriptions/subId/resourceGroups/myResourceGroup";
3538

@@ -45,6 +48,8 @@ public GetAzureResourceGroupCommandTests()
4548
ResourcesClient = resourcesClientMock.Object
4649
};
4750
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
51+
mockRuntime = new MockCommandRuntime();
52+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
4853
}
4954

5055
[Fact]

src/CLU/Microsoft.Azure.Commands.Resources.Test/ResourceGroups/NewAzureResourceGroupCommandTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Test.Mocks;
1516
using Microsoft.Azure.Commands.Resources.Models;
1617
using Microsoft.Azure.Commands.ScenarioTest;
1718
using Microsoft.Azure.Commands.Test.Utilities.Common;
@@ -30,6 +31,7 @@ public class NewAzureResourceGroupCommandTests : RMTestBase
3031
private Mock<ResourcesClient> resourcesClientMock;
3132

3233
private Mock<ICommandRuntime> commandRuntimeMock;
34+
private MockCommandRuntime mockRuntime;
3335

3436
private string resourceGroupName = "myResourceGroup";
3537

@@ -53,6 +55,8 @@ public NewAzureResourceGroupCommandTests()
5355
ResourcesClient = resourcesClientMock.Object
5456
};
5557
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
58+
mockRuntime = new MockCommandRuntime();
59+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
5660

5761
tags = new[]
5862
{

src/CLU/Microsoft.Azure.Commands.Resources.Test/ResourceGroups/SetAzureResourceGroupCommandTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Common.Test.Mocks;
1516
using Microsoft.Azure.Commands.Resources.Models;
1617
using Microsoft.Azure.Commands.ScenarioTest;
1718
using Microsoft.Azure.Commands.Test.Utilities.Common;
@@ -31,6 +32,7 @@ public class SetAzureResourceGroupCommandTests : RMTestBase
3132
private Mock<ResourcesClient> resourcesClientMock;
3233

3334
private Mock<ICommandRuntime> commandRuntimeMock;
35+
private MockCommandRuntime mockRuntime;
3436

3537
private string resourceGroupName = "myResourceGroup";
3638
private string resourceGroupId = "/subscriptions/subId/resourceGroups/myResourceGroup";
@@ -47,6 +49,8 @@ public SetAzureResourceGroupCommandTests()
4749
ResourcesClient = resourcesClientMock.Object
4850
};
4951
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
52+
mockRuntime = new MockCommandRuntime();
53+
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
5054

5155
tags = new [] {new Hashtable
5256
{

0 commit comments

Comments
 (0)