private void VerifyMockVMActionInvoked(MockVMConnection vm, VMActionType actionType, params string[] parameters) { bool found = false; foreach (VMAction action in vm.History) { if (action.Action == actionType) { bool parametersDifferent = false; if (parameters.Length == action.Params.Length) { for (int i = 0; i < parameters.Length; i++) { if (parameters[i] != action.Params[i]) { parametersDifferent = true; } } } else { parametersDifferent = true; } if (!parametersDifferent) { found = true; } } } Assert.True(found, "Could not find action \"{0}\" with params \"{1}\" for VM \"{2}\"", actionType.ToString(), string.Join(", ", parameters), vm._VMName); }
public MockVMConnection AddMockVM(string vmName) { MockVMConnection mockVM = new MockVMConnection(); mockVM.VMName = vmName; vms.Add(mockVM); return(mockVM); }
private bool WaitForVMAction(MockVMConnection vm, VMActionType actionType, DateTime minimumTime, TimeSpan timeout) { DateTime start = DateTime.Now; while (DateTime.Now - start < timeout) { foreach (VMAction action in vm.History) { if (action.Time >= minimumTime && action.Action == actionType) { return(true); } } System.Threading.Thread.Sleep(100); } return(false); }
public void SetUp() { testStart = DateTime.Now; vmHash = new Dictionary <string, MockVMConnection>(); List <string[]> mockVMs = new List <string[]>(); mockVMs.Add(new string[] { "MockVMConfig1", "", "Snapshot1", "MockVMName1" }); mockVMs.Add(new string[] { "MockVMConfig2", "", "Snapshot2", "MockVMName2" }); sut = new JobManagerServiceWrapper(); foreach (string[] mockInfo in mockVMs) { MockVMConnection vmConn = sut.MockVMHost.AddMockVM(mockInfo[3]); vmHash[vmConn._VMName] = vmConn; mockInfo[1] = vmConn._Identifier; } using (TextWriter tw = new StreamWriter(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "vm_list.txt"), false)) { foreach (string[] mockInfo in mockVMs) { tw.WriteLine(string.Join(", ", mockInfo)); } } }
private void VerifyMockVMActionInvoked(MockVMConnection vm, VMActionType actionType) { VerifyMockVMActionInvoked(vm, actionType, new string[0]); }
private bool WaitForVMAction(MockVMConnection vm, VMActionType actionType, DateTime minimumTime, TimeSpan timeout) { DateTime start = DateTime.Now; while (DateTime.Now - start < timeout) { foreach (VMAction action in vm.History) { if (action.Time >= minimumTime && action.Action == actionType) { return true; } } System.Threading.Thread.Sleep(100); } return false; }
public MockVMConnection AddMockVM(string vmName) { MockVMConnection mockVM = new MockVMConnection(); mockVM.VMName = vmName; vms.Add(mockVM); return mockVM; }