public async Task Handle_WhenContextUpdatesEngagement_EngagementRecordInDatabaseReflectsUpdate() { var inputEngagement = new UpdateEngagement() { TimeDisengaged = new DateTime(1970, 10, 10) }; var context = await MockFactory.IncidentContext( nameof(PutEngagementTests) + nameof(Handle_WhenContextUpdatesEngagement_EngagementRecordInDatabaseReflectsUpdate) ); var incident = context.Incidents.FirstOrDefault(); var engagement = incident.Engagements.FirstOrDefault(); var serviceUnderTest = new PutEngagementHandler(context); var request = new PutEngagementRequest(incident.Id, engagement.Id, inputEngagement, new DummyAuthenticatedUserContext()); await serviceUnderTest.Handle(request, new System.Threading.CancellationToken()); var result = context.Engagements.First(e => e.Id == engagement.Id); Assert.AreEqual(new DateTime(1970, 10, 10), result.TimeDisengaged); }
public async Task Handle_WhenAssociatedIncidentDoesNotExist_ThrowKeyNotFoundException() { var inputEngagement = new UpdateEngagement() { TimeDisengaged = new DateTime(1070, 10, 10) }; var context = await MockFactory.IncidentContext(nameof(PutEngagementTests) + nameof(Handle_WhenAssociatedIncidentDoesNotExist_ThrowKeyNotFoundException)); var serviceUnderTest = new PutEngagementHandler(context); var request = new PutEngagementRequest(100_000, 1, inputEngagement, new DummyAuthenticatedUserContext()); await serviceUnderTest.Handle(request, new System.Threading.CancellationToken()); //Expect exception }