private void ProgressViewModelTestRun(ProgressViewModel pvm) { Assert.AreEqual("Some task...", pvm.ProgressText); //Test basic thread operation int count = 0; pvm.ActionWork = (p) => { Thread.Sleep(1000); count = 100; }; pvm.ExecuteCommand.Execute(null); Assert.AreNotEqual(100, count); pvm.Wait(); Assert.AreEqual(100, count); //Test action on completion count = 0; pvm.ActionWork = (p) => { Thread.Sleep(1000); }; pvm.ActionComplete = () => { count = 100; }; pvm.ExecuteCommand.Execute(null); Assert.AreNotEqual(100, count); pvm.Wait(); Assert.AreEqual(100, count); //Test progress = this should fail pvm.ReportsProgress = false; bool exceptionHappend = false; pvm.ActionWork = (p) => { try { p.ReportProgress(5); } catch { exceptionHappend = true; } }; pvm.ExecuteCommand.Execute(null); pvm.Wait(); Assert.IsTrue(exceptionHappend); //Test progress pvm.ReportsProgress = true; pvm.ActionWork = (p) => { p.ReportProgress(50); Thread.Sleep(1000); }; int progress = 0; pvm.ActionProgressUpdate = (x) => { progress = x; }; pvm.ExecuteCommand.Execute(null); Assert.AreNotEqual(50, progress); pvm.Wait(); Assert.AreEqual(50, progress); }