Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from simongh/add-interfaces
Converted to .Net Standard
- Loading branch information
Showing
27 changed files
with
1,466 additions
and
1,420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ bin | |
obj | ||
*.suo | ||
*.vspscc | ||
/Sources/.vs | ||
/Sources/TinyWorkflow/project.lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,75 @@ | ||
using System; | ||
using System.Threading; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using TinyWorkflow.Tests.States; | ||
using System.Threading; | ||
|
||
namespace TinyWorkflow.Tests | ||
{ | ||
[TestClass] | ||
public class AsynchStepTest | ||
{ | ||
Workflow<SimpleState> temporaryWorkflow; | ||
[TestMethod] | ||
public void RunOneAsynchStep() | ||
{ | ||
temporaryWorkflow = new Workflow<SimpleState>() | ||
.DoAsynch(EasyAction) | ||
.Block() | ||
.Do(EasyAsynchronousTestValidation); | ||
temporaryWorkflow.Start(new SimpleState()); | ||
Thread.Sleep(3000); | ||
} | ||
[TestClass] | ||
public class AsynchStepTest | ||
{ | ||
private IWorkflow<SimpleState> temporaryWorkflow; | ||
|
||
[TestMethod] | ||
public void RunOneAsynchStep() | ||
{ | ||
temporaryWorkflow = new Workflow<SimpleState>() | ||
.DoAsynch(EasyAction) | ||
.Block() | ||
.Do(EasyAsynchronousTestValidation); | ||
temporaryWorkflow.Start(new SimpleState()); | ||
Thread.Sleep(3000); | ||
} | ||
|
||
[TestMethod] | ||
public void RunMultipleAsynchStep() | ||
{ | ||
temporaryWorkflow = new Workflow<SimpleState>() | ||
.DoAsynch(EasyActionAsynch1,EasyActionAsynch2,EasyActionAsynch3) | ||
.Block(3) | ||
.Do(AsynchronousTestValidation); | ||
temporaryWorkflow.Start(new SimpleState()); | ||
Thread.Sleep(3000); | ||
} | ||
[TestMethod] | ||
public void RunMultipleAsynchStep() | ||
{ | ||
temporaryWorkflow = new Workflow<SimpleState>() | ||
.DoAsynch(EasyActionAsynch1, EasyActionAsynch2, EasyActionAsynch3) | ||
.Block(3) | ||
.Do(AsynchronousTestValidation); | ||
temporaryWorkflow.Start(new SimpleState()); | ||
Thread.Sleep(3000); | ||
} | ||
|
||
public void EasyAsynchronousTestValidation(SimpleState state) | ||
{ | ||
Assert.AreEqual(1, state.StateFullVariable); | ||
} | ||
public void EasyAsynchronousTestValidation(SimpleState state) | ||
{ | ||
Assert.AreEqual(1, state.StateFullVariable); | ||
} | ||
|
||
public void AsynchronousTestValidation(SimpleState state) | ||
{ | ||
Assert.AreEqual(10, state.StateFullVariableAsynch1); | ||
Assert.AreEqual(20, state.StateFullVariableAsynch2); | ||
Assert.AreEqual(30, state.StateFullVariableAsynch3); | ||
} | ||
public void AsynchronousTestValidation(SimpleState state) | ||
{ | ||
Assert.AreEqual(10, state.StateFullVariableAsynch1); | ||
Assert.AreEqual(20, state.StateFullVariableAsynch2); | ||
Assert.AreEqual(30, state.StateFullVariableAsynch3); | ||
} | ||
|
||
public void EasyAction(SimpleState state) | ||
{ | ||
Thread.Sleep(1000); | ||
state.StateFullVariable = 1; | ||
temporaryWorkflow.Unblock(); | ||
} | ||
public void EasyAction(SimpleState state) | ||
{ | ||
Thread.Sleep(1000); | ||
state.StateFullVariable = 1; | ||
temporaryWorkflow.Unblock(); | ||
} | ||
|
||
public void EasyActionAsynch1(SimpleState state) | ||
{ | ||
Thread.Sleep(1200); | ||
state.StateFullVariableAsynch1 = 10; | ||
temporaryWorkflow.Unblock(); | ||
} | ||
public void EasyActionAsynch1(SimpleState state) | ||
{ | ||
Thread.Sleep(1200); | ||
state.StateFullVariableAsynch1 = 10; | ||
temporaryWorkflow.Unblock(); | ||
} | ||
|
||
public void EasyActionAsynch2(SimpleState state) | ||
{ | ||
Thread.Sleep(700); | ||
state.StateFullVariableAsynch2 = 20; | ||
temporaryWorkflow.Unblock(); | ||
} | ||
public void EasyActionAsynch2(SimpleState state) | ||
{ | ||
Thread.Sleep(700); | ||
state.StateFullVariableAsynch2 = 20; | ||
temporaryWorkflow.Unblock(); | ||
} | ||
|
||
public void EasyActionAsynch3(SimpleState state) | ||
{ | ||
Thread.Sleep(1000); | ||
state.StateFullVariableAsynch3 = 30; | ||
temporaryWorkflow.Unblock(); | ||
} | ||
} | ||
} | ||
public void EasyActionAsynch3(SimpleState state) | ||
{ | ||
Thread.Sleep(1000); | ||
state.StateFullVariableAsynch3 = 30; | ||
temporaryWorkflow.Unblock(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using TinyWorkflow.Tests.States; | ||
|
||
namespace TinyWorkflow.Tests | ||
{ | ||
[TestClass] | ||
public class BlockSimpleStepTest | ||
{ | ||
[TestMethod] | ||
public void SimpleStepBlock() | ||
{ | ||
Workflow<SimpleState> workflow = new Workflow<SimpleState>() | ||
.Do(ActionBeforeBlock) | ||
.Block() | ||
.Do(ActionAfterBlock); | ||
[TestClass] | ||
public class BlockSimpleStepTest | ||
{ | ||
[TestMethod] | ||
public void SimpleStepBlock() | ||
{ | ||
var workflow = new Workflow<SimpleState>() | ||
.Do(ActionBeforeBlock) | ||
.Block() | ||
.Do(ActionAfterBlock); | ||
|
||
workflow.Start(new SimpleState()); | ||
Assert.AreEqual(5, workflow.Workload.StateFullVariable); | ||
workflow.Unblock(); | ||
Assert.AreEqual(10, workflow.Workload.StateFullVariable); | ||
} | ||
workflow.Start(new SimpleState()); | ||
Assert.AreEqual(5, workflow.Workload.StateFullVariable); | ||
workflow.Unblock(); | ||
Assert.AreEqual(10, workflow.Workload.StateFullVariable); | ||
} | ||
|
||
public void ActionBeforeBlock(SimpleState state) | ||
{ | ||
state.StateFullVariable = 5; | ||
} | ||
public void ActionBeforeBlock(SimpleState state) | ||
{ | ||
state.StateFullVariable = 5; | ||
} | ||
|
||
public void ActionAfterBlock(SimpleState state) | ||
{ | ||
state.StateFullVariable = 10; | ||
} | ||
} | ||
} | ||
public void ActionAfterBlock(SimpleState state) | ||
{ | ||
state.StateFullVariable = 10; | ||
} | ||
} | ||
} |
Oops, something went wrong.