mirror of
https://github.com/ditkrg/DIT.Workflower.git
synced 2026-01-22 13:56:43 +00:00
Use KeyNotFound exception
This commit is contained in:
parent
ab80dad816
commit
17218ea291
@ -25,7 +25,7 @@ public class DefaultWorkflowFactory<TState, TCommand, TContext> : IWorkflowFacto
|
||||
.FirstOrDefault(x => x.Reference == reference);
|
||||
|
||||
if (service is null)
|
||||
throw new ArgumentOutOfRangeException(nameof(version), $"Workflow reference {id}.v{version} does not exist");
|
||||
throw new KeyNotFoundException($"Workflow reference {id}.v{version} does not exist");
|
||||
|
||||
return service;
|
||||
}
|
||||
|
||||
@ -75,4 +75,19 @@ public class DependencyInjectionTests
|
||||
Assert.Equal("PhoneState_PhoneCommand_PhoneCall", workflow.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnknownWorkflowReferenceThrows()
|
||||
{
|
||||
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>>();
|
||||
Assert.Throws<KeyNotFoundException>(() => workflowFactory.CreateWorkflow("unknown"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user