Skip to content

Commit a30581d

Browse files
committed
Update Tests
1 parent b311f0a commit a30581d

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

src/CLU/Commands.ScenarioTests.ResourceManager.Common/PSCmdletExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,11 @@ public static void SetCommandRuntimeMock(this PSCmdlet cmdlet, ICommandRuntime v
5353
var property = GetInternalProperty("CommandRuntime", typeof (ICommandRuntime));
5454
property.SetValue(cmdlet, value);
5555
}
56+
57+
public static ICommandRuntime GetCommandRuntimeMock(this PSCmdlet cmdlet)
58+
{
59+
var property = GetInternalProperty("CommandRuntime", typeof(ICommandRuntime));
60+
return (ICommandRuntime)property.GetValue(cmdlet);
61+
}
5662
}
5763
}

src/CLU/Microsoft.Azure.Commands.Compute.Test/GetAzureVMSizeCommandTests.cs

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,28 @@ public void GetVirtualMachineSizesFromLocation()
7070
var computeManagementClientMock = new Mock<IComputeManagementClient>();
7171
vmSizesMock = new Mock<IVirtualMachineSizesOperations>();
7272
computeManagementClientMock.Setup(f => f.VirtualMachineSizes).Returns(vmSizesMock.Object);
73-
SetupListForVirtualMachineSizeAsync("westus", new List<VirtualMachineSize>());
73+
var vmSizeList = new List<VirtualMachineSize>
74+
{
75+
new VirtualMachineSize
76+
{
77+
Name = "1",
78+
MaxDataDiskCount = 1,
79+
MemoryInMB = 1,
80+
NumberOfCores = 1,
81+
OsDiskSizeInMB = 1,
82+
ResourceDiskSizeInMB = 1
83+
},
84+
new VirtualMachineSize
85+
{
86+
Name = "2",
87+
MaxDataDiskCount = 2,
88+
MemoryInMB = 2,
89+
NumberOfCores = 2,
90+
OsDiskSizeInMB = 2,
91+
ResourceDiskSizeInMB = 2
92+
}
93+
};
94+
SetupListForVirtualMachineSizeAsync("westus", vmSizeList);
7495

7596
var progressLoggerMock = new Mock<Action<string>>();
7697
var errorLoggerMock = new Mock<Action<string>>();
@@ -83,19 +104,32 @@ public void GetVirtualMachineSizesFromLocation()
83104
var profile = new AzureRMProfile(_dataStore);
84105
profile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault());
85106
profile.Context = new AzureContext(new AzureSubscription(), new AzureAccount(), profile.Environments["foo"]);
86-
GetAzureVMSizeCommand cmdlt = new GetAzureVMSizeCommand
107+
GetAzureVMSizeCommand cmdlet = new GetAzureVMSizeCommand
87108
{
88109
ComputeClient = computeClient,
89110
Location = "westus"
90111
};
91-
cmdlt.DataStore = _dataStore;
92-
cmdlt.SetCommandRuntimeMock(_commandRuntimeMock);
93-
cmdlt.DefaultProfile = profile;
112+
cmdlet.DataStore = _dataStore;
113+
cmdlet.SetCommandRuntimeMock(_commandRuntimeMock);
114+
cmdlet.DefaultProfile = profile;
94115

95116
// Act
96-
cmdlt.InvokeBeginProcessing();
97-
cmdlt.ExecuteCmdlet();
98-
cmdlt.InvokeEndProcessing();
117+
cmdlet.InvokeBeginProcessing();
118+
cmdlet.ExecuteCmdlet();
119+
cmdlet.InvokeEndProcessing();
120+
121+
var runtime = cmdlet.GetCommandRuntimeMock() as MockCommandRuntime;
122+
Assert.True(runtime.OutputPipeline.Count == vmSizeList.Count);
123+
for (int i = 0; i < runtime.OutputPipeline.Count; i++)
124+
{
125+
var item = runtime.OutputPipeline[i] as VirtualMachineSize;
126+
Assert.True(item.Name == vmSizeList[i].Name);
127+
Assert.True(item.MaxDataDiskCount == vmSizeList[i].MaxDataDiskCount);
128+
Assert.True(item.MemoryInMB == vmSizeList[i].MemoryInMB);
129+
Assert.True(item.NumberOfCores == vmSizeList[i].NumberOfCores);
130+
Assert.True(item.OsDiskSizeInMB == vmSizeList[i].OsDiskSizeInMB);
131+
Assert.True(item.ResourceDiskSizeInMB == vmSizeList[i].ResourceDiskSizeInMB);
132+
}
99133

100134
return;
101135
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class NewAzureResourceGroupDeploymentCommandTests : RMTestBase
4040

4141
private string templateFile = @"Resources\sampleTemplateFile.json";
4242

43-
private string storageAccountName = "myStorageAccount";
43+
//private string storageAccountName = "myStorageAccount";
4444

4545
public NewAzureResourceGroupDeploymentCommandTests()
4646
{

0 commit comments

Comments
 (0)