public void GetVmStatsCommandFail() { // Use WMI to find existing VMs List<String> vmNames = new List<String>(); vmNames.Add("FakeVM"); var cmd = new { hostGuid = "FAKEguid", hostName = AgentSettings.Default.host, vmNames = vmNames }; JToken tok = JToken.FromObject(cmd); HypervResourceController controller = new HypervResourceController(); // Act dynamic jsonResult = controller.GetVmStatsCommand(tok); // Assert dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer]; Assert.IsTrue((bool)ans.result, (string)ans.details); // always succeeds, fake VM means no answer for the named VM }
public void GetVmStatsCommand() { // Use WMI to find existing VMs List<String> vmNames = WmiCalls.GetVmElementNames(); var cmd = new { hostGuid = "FAKEguid", hostName = AgentSettings.Default.host, vmNames = vmNames }; JToken tok = JToken.FromObject(cmd); HypervResourceController controller = new HypervResourceController(); // Act dynamic jsonResult = controller.GetVmStatsCommand(tok); // Assert dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer]; Assert.IsTrue((bool)ans.result, (string)ans.details); }