public async Task GetGlobalActionsHandler_Handle_ReturnAllGlobalActions() { var globalActionIndex = new Dictionary <long, Domain.Playbook.Action>(); var globalActionToFind = new Domain.Playbook.Action() { Id = 5, Name = "Test Action" }; var additionalAction = new Domain.Playbook.Action() { Id = 4, Name = "UnusedAction" }; if (!globalActionIndex.TryAdd(globalActionToFind.Id, globalActionToFind)) { throw new Exception("Test setup failure when populating dictionary"); } if (!globalActionIndex.TryAdd(additionalAction.Id, additionalAction)) { throw new Exception("Test setup failure when populating dictionary"); } var serviceUnderTest = new GetGlobalActionsHandler(globalActionIndex); var request = new GetGlobalActionsRequest(null); var result = await serviceUnderTest .Handle(request, cancellationToken : new CancellationToken()) .ConfigureAwait(continueOnCapturedContext: false); Assert.AreEqual(globalActionIndex.Values.ElementAt(0), result.ElementAt(0)); }
public async Task GetGlobalActionsHandler_Handle__WhenNoGlobalActionsReturn_Empty_Enumerable() { var globalActionIndex = new Dictionary <long, Domain.Playbook.Action>(); var serviceUnderTest = new GetGlobalActionsHandler(globalActionIndex); var request = new GetGlobalActionsRequest(null); var result = await serviceUnderTest .Handle(request, cancellationToken : new CancellationToken()) .ConfigureAwait(continueOnCapturedContext: false); Assert.AreEqual(0, result.Count()); }