Here comes my first Workflow in Unit Tests. I tend to think that "Dot Net" inevitably turns into "Brace Net"... :-)
[TestClass] public class BackupTests { [TestMethod, ExpectedException(typeof(InvalidWorkflowException))] public void IndexArgumentMissingTest() { Activity backup = new BackupFilesActivity { Copier = new MockCopier() }; var sequence = new Sequence { Activities = { backup } }; WorkflowInvoker.Invoke(sequence); } [TestMethod, ExpectedException(typeof(MyException))] public void CopyFailsTest() { var index = new IndexInfo() { ID = 1 }; Activity backup = new BackupFilesActivity { Copier = new MockCopier(new MyException()), }; var inputs = new Dictionary<string, object>() { { "Index", index } }; WorkflowInvoker.Invoke(backup, inputs); } [TestMethod] public void MockCopyWorksTest() { var index = new IndexInfo() { ID = 1 }; Activity backup = new BackupFilesActivity { Copier = new MockCopier(), Index = new InArgument<IndexInfo>((ctx) => index) }; var sequence = new Sequence { Activities = { backup } }; WorkflowInvoker.Invoke(sequence); } }
No comments:
Post a Comment