public async Task GetEventTypesHandler_Handle_ReturnAllEventTypes() { var eventTypeIndex = new Dictionary <long, EventType>(); var eventTypeToFind = new EventType() { Id = 5, Name = "Test Event Type" }; var additionalEventType = new EventType() { Id = 4, Name = "UnusedEventType" }; if (!eventTypeIndex.TryAdd(eventTypeToFind.Id, eventTypeToFind)) { throw new Exception("Test setup failure when populating dictionary"); } if (!eventTypeIndex.TryAdd(additionalEventType.Id, additionalEventType)) { throw new Exception("Test setup failure when populating dictionary"); } var serviceUnderTest = new GetEventTypesHandler(eventTypeIndex); var request = new GetEventTypesRequest(null); var result = await serviceUnderTest .Handle(request, cancellationToken : new CancellationToken()) .ConfigureAwait(continueOnCapturedContext: false); Assert.AreEqual(eventTypeIndex.Values.ElementAt(0), result.ElementAt(0)); }
public async Task GetEventTypesHandler_Handle_WhenNoEventTypes_Return_Empty_Enumerable() { var eventTypeIndex = new Dictionary <long, EventType>(); var serviceUnderTest = new GetEventTypesHandler(eventTypeIndex); var request = new GetEventTypesRequest(null); var result = await serviceUnderTest .Handle(request, cancellationToken : new CancellationToken()) .ConfigureAwait(continueOnCapturedContext: false); Assert.AreEqual(0, result.Count()); }