Improvements

This commit is contained in:
2022-06-18 11:22:12 +03:00
parent 98e02edb9c
commit 8d9b7d4134
6 changed files with 49 additions and 11 deletions

View File

@@ -40,7 +40,7 @@ public class DependencyInjectionTests
var sp = sc.BuildServiceProvider();
var workflowFactory = sp.GetService<IWorkflowFactory<PhoneState, PhoneCommand, PhoneCall>>()!;
var workflowFactory = sp.GetRequiredService<IWorkflowFactory<PhoneState, PhoneCommand, PhoneCall>>();
var v1 = workflowFactory.CreateWorkflow(id);
@@ -58,4 +58,21 @@ public class DependencyInjectionTests
Assert.Equal(2, v2.GetAllowedTransitions(PhoneState.Ringing).Count);
}
[Fact]
public void IdGenerationTest()
{
var sc = new ServiceCollection();
sc.AddWorkflowDefinition<PhoneState, PhoneCommand, PhoneCall>(version: 1)
.From(PhoneState.Idle)
.On(PhoneCommand.IncomingCall)
.To(PhoneState.Ringing);
var sp = sc.BuildServiceProvider();
var workflowFactory = sp.GetRequiredService<IWorkflowFactory<PhoneState, PhoneCommand, PhoneCall>>();
var workflow = workflowFactory.CreateWorkflow();
Assert.Equal("PhoneState_PhoneCommand_PhoneCall", workflow.Id);
}
}