public async Task Handle_WhenContextSavesEngagement_ReturnCorrectEngagementWithUpdateTime() { var engagementTimeFloor = DateTime.UtcNow; var inputEngagement = new NewEngagement() { Participant = new Participant() { Alias = "test", Team = "alsoTest", Role = "stillTest" } }; var context = await MockFactory.IncidentContext( nameof(PostEngagementTests) + "one" ); var incident = context.Incidents.FirstOrDefault(); var serviceUnderTest = new PostEngagementHandler( context ); var request = new PostEngagementRequest(incident.Id, inputEngagement, new DummyAuthenticatedUserContext()); var result = await serviceUnderTest.Handle(request, new System.Threading.CancellationToken()); Assert.AreEqual("test", result.Participant.Alias); Assert.AreEqual("alsoTest", result.Participant.Team); Assert.AreEqual("stillTest", result.Participant.Role); Assert.IsTrue(DateTime.UtcNow >= result.TimeEngaged); Assert.IsTrue(engagementTimeFloor <= result.TimeEngaged); Assert.IsNull(result.TimeDisengaged); }
public async Task Handle_WhenAssociatedIncidentDoesNotExist_ThrowKeyNotFoundException() { var engagementTimeFloor = DateTime.UtcNow; var inputEngagement = new NewEngagement() { Participant = new Participant() { Alias = "test", Team = "alsoTest", Role = "stillTest" } }; var serviceUnderTest = new PostEngagementHandler(await MockFactory.IncidentContext(nameof(PostEngagementTests) /*+ nameof(Handle_WhenAssociatedIncidentDoesNotExist_ThrowKeyNotFoundException)*/)); var request = new PostEngagementRequest(100_000, inputEngagement, new DummyAuthenticatedUserContext()); var result = await serviceUnderTest.Handle(request, new System.Threading.CancellationToken()); //Expect exception }