public async Task GetOverview_GivenAppointmentWithParticipation_SummaryCountsCorrect() { GetDatabaseContext getContext = ContextUtilities.CreateInMemoryContext(_output); Event yourEvent; int johnId; // Arrange using (IDatabaseContext context = getContext()) { User john = ContextUtilities.CreateJohnDoe(); User participantWithExplicitNoAnswer = ContextUtilities.CreateRandomUser(); User participantAccepted = ContextUtilities.CreateRandomUser(); User participantDeclined = ContextUtilities.CreateRandomUser(); yourEvent = DummyEvent(john); context.Events.Add(yourEvent); context.EventParticipations.Add(new EventParticipation { Participant = john, Event = yourEvent }); context.EventParticipations.Add(new EventParticipation { Participant = participantWithExplicitNoAnswer, Event = yourEvent }); context.EventParticipations.Add(new EventParticipation { Participant = participantAccepted, Event = yourEvent }); context.EventParticipations.Add(new EventParticipation { Participant = participantDeclined, Event = yourEvent }); EntityEntry <Appointment> appointmentEntry = context.Appointments.Add(new Appointment { Event = yourEvent, StartTime = DateTime.UtcNow + TimeSpan.FromDays(1) }); context.AppointmentParticipations.Add(new AppointmentParticipation { Participant = participantWithExplicitNoAnswer, Appointment = appointmentEntry.Entity, AppointmentParticipationAnswer = null }); context.AppointmentParticipations.Add(new AppointmentParticipation { Participant = participantAccepted, Appointment = appointmentEntry.Entity, AppointmentParticipationAnswer = AppointmentParticipationAnswer.Accepted }); context.AppointmentParticipations.Add(new AppointmentParticipation { Participant = participantDeclined, Appointment = appointmentEntry.Entity, AppointmentParticipationAnswer = AppointmentParticipationAnswer.Declined }); await context.SaveChangesAsync(); johnId = john.Id; } // Act (ParticipateEventController participateEventController, _) = CreateController(getContext, johnId); IActionResult response = await participateEventController.GetOverview(); // Assert Assert.IsType <OkObjectResult>(response); var okObjectResult = (OkObjectResult)response; var eventOverview = okObjectResult.Value as EventOverview; Assert.NotNull(eventOverview); Assert.Empty(eventOverview.PublicEvents); Assert.Single(eventOverview.YourEvents); EventOverviewInformation loadedYourEvent = eventOverview.YourEvents[0]; Assert.Equal(yourEvent.Id, loadedYourEvent.EventId); Assert.Equal(4, loadedYourEvent.ViewEventInformation.TotalParticipants); Assert.NotNull(loadedYourEvent.LatestAppointmentInformation); Assert.Equal(1, loadedYourEvent.LatestAppointmentInformation.AcceptedParticipants); Assert.Equal(1, loadedYourEvent.LatestAppointmentInformation.DeclinedParticipants); Assert.Equal(2, loadedYourEvent.LatestAppointmentInformation.NotAnsweredParticipants); }