-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…r-admins expose an endpoint to get all conferences for today
- Loading branch information
Showing
16 changed files
with
329 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using VideoApi.DAL.Queries.Core; | ||
using VideoApi.Domain; | ||
|
||
namespace VideoApi.DAL.Queries | ||
{ | ||
public class GetConferencesTodayQuery : IQuery | ||
{ | ||
} | ||
|
||
public class GetConferencesTodayQueryHandler : IQueryHandler<GetConferencesTodayQuery, List<Conference>> | ||
{ | ||
private readonly VideoApiDbContext _context; | ||
|
||
public GetConferencesTodayQueryHandler(VideoApiDbContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public async Task<List<Conference>> Handle(GetConferencesTodayQuery query) | ||
{ | ||
var today = DateTime.Today; | ||
var tomorrow = DateTime.Today.AddDays(1); | ||
return await _context.Conferences | ||
.Include("Participants.ParticipantStatuses") | ||
.Include("ConferenceStatuses") | ||
.Include("Tasks").AsNoTracking() | ||
.Where(x => x.ScheduledDateTime >= today && x.ScheduledDateTime < tomorrow) | ||
.OrderBy(x => x.ScheduledDateTime) | ||
.ToListAsync(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
VideoAPI/VideoApi.IntegrationTests/Api/Conferences.feature.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
VideoAPI/VideoApi.IntegrationTests/Contexts/ConferenceTestContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using VideoApi.Contract.Responses; | ||
using VideoApi.Domain; | ||
|
||
namespace VideoApi.IntegrationTests.Contexts | ||
{ | ||
public class ConferenceTestContext | ||
{ | ||
public ConferenceTestContext() | ||
{ | ||
SeededConferences = new List<Guid>(); | ||
} | ||
|
||
public ConferenceDetailsResponse ConferenceDetails { get; set; } | ||
public Conference SeededConference { get; set; } | ||
public List<Guid> SeededConferences { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ public async Task should_update_status_to_done(TaskType taskType) | |
const string updatedBy = "[email protected]"; | ||
var conferenceWithAlert = new ConferenceBuilder(true) | ||
.WithParticipant(UserRole.Individual, "Claimant") | ||
.WithParticipantTask(body, taskType) | ||
.WithTask(body, taskType) | ||
.Build(); | ||
var seededConference = await TestDataManager.SeedConference(conferenceWithAlert); | ||
_newConferenceId = seededConference.Id; | ||
|
@@ -75,7 +75,7 @@ public async Task should_throw_task_not_found_exception() | |
const string updatedBy = "[email protected]"; | ||
var conferenceWithAlert = new ConferenceBuilder(true) | ||
.WithParticipant(UserRole.Individual, "Claimant") | ||
.WithParticipantTask(body, TaskType.Participant) | ||
.WithParticipantTask(body) | ||
.Build(); | ||
var seededConference = await TestDataManager.SeedConference(conferenceWithAlert); | ||
_newConferenceId = seededConference.Id; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
VideoAPI/VideoApi.IntegrationTests/Database/Queries/GetConferencesTodayQueryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
using Testing.Common.Helper.Builders.Domain; | ||
using VideoApi.DAL; | ||
using VideoApi.DAL.Queries; | ||
using VideoApi.Domain; | ||
using VideoApi.Domain.Enums; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace VideoApi.IntegrationTests.Database.Queries | ||
{ | ||
public class GetConferencesTodayQueryTests : DatabaseTestsBase | ||
{ | ||
private GetConferencesTodayQueryHandler _handler; | ||
private Guid _newConferenceId1; | ||
private Guid _newConferenceId2; | ||
private Guid _newConferenceId3; | ||
private Guid _newConferenceId4; | ||
private Guid _newConferenceId5; | ||
private Guid _newConferenceId6; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
var context = new VideoApiDbContext(VideoBookingsDbContextOptions); | ||
_handler = new GetConferencesTodayQueryHandler(context); | ||
_newConferenceId1 = Guid.Empty; | ||
_newConferenceId2 = Guid.Empty; | ||
_newConferenceId3 = Guid.Empty; | ||
_newConferenceId4 = Guid.Empty; | ||
_newConferenceId5 = Guid.Empty; | ||
_newConferenceId6 = Guid.Empty; | ||
} | ||
|
||
[TearDown] | ||
public async Task TearDown() | ||
{ | ||
TestContext.WriteLine("Cleaning conferences for GetConferencesTodayQueryHandler"); | ||
await TestDataManager.RemoveConference(_newConferenceId1); | ||
await TestDataManager.RemoveConference(_newConferenceId2); | ||
await TestDataManager.RemoveConference(_newConferenceId3); | ||
await TestDataManager.RemoveConference(_newConferenceId4); | ||
await TestDataManager.RemoveConference(_newConferenceId5); | ||
await TestDataManager.RemoveConference(_newConferenceId6); | ||
} | ||
|
||
[Test] | ||
public async Task should_get_conference_today() | ||
{ | ||
var today = DateTime.Today.AddHours(10); | ||
var tomorrow = DateTime.Today.AddDays(1).AddHours(10); | ||
var yesterday = DateTime.Today.AddDays(1).AddHours(10); | ||
var conference1 = new ConferenceBuilder(true, scheduledDateTime: yesterday) | ||
.WithParticipant(UserRole.Representative, "Defendant") | ||
.WithParticipant(UserRole.Judge, null) | ||
.WithConferenceStatus(ConferenceState.Closed) | ||
.Build(); | ||
_newConferenceId1 = conference1.Id; | ||
|
||
var conference2 = new ConferenceBuilder(true, scheduledDateTime: today) | ||
.WithParticipant(UserRole.Representative, "Defendant") | ||
.WithParticipant(UserRole.Judge, null) | ||
.WithConferenceStatus(ConferenceState.InSession) | ||
.Build(); | ||
_newConferenceId2 = conference2.Id; | ||
|
||
var conference3 = new ConferenceBuilder(true, scheduledDateTime: tomorrow) | ||
.WithParticipant(UserRole.Representative, "Defendant") | ||
.WithParticipant(UserRole.Judge, null) | ||
.WithConferenceStatus(ConferenceState.Paused) | ||
.Build(); | ||
_newConferenceId3 = conference3.Id; | ||
|
||
var conference4 = new ConferenceBuilder(true, scheduledDateTime: yesterday) | ||
.WithParticipant(UserRole.Representative, "Defendant") | ||
.WithParticipant(UserRole.Judge, null) | ||
.WithConferenceStatus(ConferenceState.Suspended) | ||
.Build(); | ||
_newConferenceId4 = conference4.Id; | ||
|
||
var conference5 = new ConferenceBuilder(true, scheduledDateTime: tomorrow) | ||
.WithParticipant(UserRole.Representative, "Defendant") | ||
.WithParticipant(UserRole.Judge, null) | ||
.WithConferenceStatus(ConferenceState.Suspended) | ||
.Build(); | ||
_newConferenceId5 = conference5.Id; | ||
|
||
var conference6 = new ConferenceBuilder(true, scheduledDateTime: today) | ||
.WithParticipant(UserRole.Representative, "Defendant") | ||
.WithParticipant(UserRole.Judge, null) | ||
.Build(); | ||
_newConferenceId6 = conference6.Id; | ||
|
||
await TestDataManager.SeedConference(conference1); | ||
await TestDataManager.SeedConference(conference2); | ||
await TestDataManager.SeedConference(conference3); | ||
await TestDataManager.SeedConference(conference4); | ||
await TestDataManager.SeedConference(conference5); | ||
await TestDataManager.SeedConference(conference6); | ||
|
||
var expectedConferences = new List<Conference> {conference2, conference6}; | ||
var conferences = await _handler.Handle(new GetConferencesTodayQuery()); | ||
|
||
conferences.Should().NotBeEmpty(); | ||
conferences.Select(x => x.Id).Should().BeEquivalentTo(expectedConferences.Select(x => x.Id)); | ||
conferences.Count.Should().Be(expectedConferences.Count); | ||
} | ||
} | ||
} |
Oops, something went wrong.