public async Task Should_return_ok_result_for_given_conference_id_and_participants() { MockQueryHandler .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>())) .ReturnsAsync(TestConference); var result = await Controller.GetParticipantsByConferenceId(TestConference.Id); var typedResult = (OkObjectResult)result; typedResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var participantsSummary = (List <ParticipantSummaryResponse>)typedResult.Value; participantsSummary.Count.Should().Be(5); var participant = participantsSummary[1]; var exspectedParticipant = TestConference.Participants[1]; participant.CaseGroup.Should().Be(exspectedParticipant.CaseTypeGroup); participant.Id.Should().Be(exspectedParticipant.Id); participant.Username.Should().Be(exspectedParticipant.Username); participant.DisplayName.Should().Be(exspectedParticipant.DisplayName); participant.FirstName.Should().Be(exspectedParticipant.FirstName); participant.LastName.Should().Be(exspectedParticipant.LastName); participant.Status.Should().Be(exspectedParticipant.State); participant.UserRole.Should().Be(exspectedParticipant.UserRole); participant.HearingRole.Should().Be(exspectedParticipant.HearingRole); participant.Representee.Should().Be(exspectedParticipant.Representee); participant.ContactEmail.Should().Be(exspectedParticipant.ContactEmail); participant.ContactTelephone.Should().Be(exspectedParticipant.ContactTelephone); }
public void TestInitialize() { var judgeFirstnames = new List <string> { "JudgeName1", "JudgeName2", "JudgeName3" }; MockQueryHandler .Setup(x => x.Handle <GetDistinctJudgeListByFirstNameQuery, List <string> >(It.IsAny <GetDistinctJudgeListByFirstNameQuery>())) .ReturnsAsync(judgeFirstnames); }
public async Task Should_remove_given_participants_from_conference() { var conferenceId = TestConference.Id; var participant = TestConference.GetParticipants()[1]; await Controller.RemoveParticipantFromConferenceAsync(conferenceId, participant.Id); MockQueryHandler.Verify(m => m.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()), Times.Once); MockCommandHandler.Verify(c => c.Handle(It.Is <RemoveParticipantsFromConferenceCommand>(x => x.Participants[0].Id == participant.Id)), Times.Once); }
public async Task Should_get_judge_list_response() { var result = await Controller.GetDistinctJudgeNamesAsync(); MockQueryHandler.Verify(m => m.Handle <GetDistinctJudgeListByFirstNameQuery, List <string> >(It.IsAny <GetDistinctJudgeListByFirstNameQuery>()), Times.Once); result.Should().NotBeNull(); result.Should().BeAssignableTo <OkObjectResult>(); var response = result.As <OkObjectResult>().Value.As <JudgeNameListResponse>(); response.FirstNames.Count.Should().Be(3); }
public async Task Should_return_notfound_with_no_matching_conference() { MockQueryHandler .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>())) .ReturnsAsync((VideoApi.Domain.Conference)null); var result = await Controller.RemoveParticipantFromConferenceAsync(Guid.NewGuid(), Guid.NewGuid()); var typedResult = (NotFoundResult)result; typedResult.Should().NotBeNull(); }
public async Task Should_return_badrequest_when_request_is_null() { MockQueryHandler .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>())) .ReturnsAsync((VideoApi.Domain.Conference)null); var result = await Controller.SaveHeartbeatDataForParticipantAsync(Guid.Empty, Guid.Empty, null); var typedResult = (BadRequestResult)result; typedResult.Should().NotBeNull(); }
public void TestInitialize() { _updateParticipantRequest = new UpdateParticipantRequest { Fullname = "Test Name", DisplayName = "Test N", Representee = "Represent" }; MockQueryHandler .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>())) .ReturnsAsync(TestConference); }
public async Task Should_ReturnAll() { var words = new[] { new LearningItem("salut", new [] { "hello, goodbye" }), new LearningItem("maison", "house") }; var mockHandler = new MockQueryHandler <FindItemsQuery, LearningItem[]>().ReturnsForAll(words).Handler; var controller = new WordsController(null, mockHandler); var result = await controller.Words(); result.ShouldBeEquivalentTo(words); }
public void TestInitialize() { MockQueryHandler .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>())) .ReturnsAsync(TestConference); var heartbeats = new List <Heartbeat> { new Heartbeat(TestConference.Id, TestConference.Participants.First().Id, 1, 2, 3, 4, 5, 6, 7, 8, DateTime.MaxValue, "chrome", "1", "Mac OS X", "10.15.7") }; MockQueryHandler .Setup(x => x.Handle <GetHeartbeatsFromTimePointQuery, IList <Heartbeat> >(It.IsAny <GetHeartbeatsFromTimePointQuery>())) .ReturnsAsync(heartbeats); }
public async Task Should_AddWord(string word, string[] answers) { var data = new AddWordPostModel { Word = word, Answers = answers }; var mockCommandHandler = new MockCommandHandler <AddWordCommand>().ReturnsForAll().Handler; var mockQueryHandler = new MockQueryHandler <FindItemsQuery, LearningItem[]>() .ReturnsForAll(new [] { new LearningItem(word, answers) }) .Handler; var controller = new WordsController(mockCommandHandler, mockQueryHandler); var result = await controller.AddWord(data); result.Should().BeOfType <CreatedResult>(); var createdResult = (CreatedResult)result; createdResult.StatusCode.Should().Be(201); createdResult.Location.Should().MatchRegex(@"\/Words\/[{(]?[0-9A-Fa-f]{8}[-]?([0-9A-Fa-f]{4}[-]?){3}[0-9A-Fa-f]{12}[)}]?"); }
public async Task Should_get_heartbeatResponses() { var conferenceId = TestConference.Id; var participantId = TestConference.GetParticipants()[1].Id; var result = await Controller.GetHeartbeatDataForParticipantAsync(conferenceId, participantId); MockQueryHandler.Verify(m => m.Handle <GetHeartbeatsFromTimePointQuery, IList <Heartbeat> >(It.IsAny <GetHeartbeatsFromTimePointQuery>()), Times.Once); result.Should().NotBeNull(); result.Should().BeAssignableTo <OkObjectResult>(); var responses = result.As <OkObjectResult>().Value.As <IEnumerable <ParticipantHeartbeatResponse> >().ToList(); responses.Should().NotBeNull().And.NotBeEmpty().And.NotContainNulls(); var heartbeatResponse = responses.First().As <ParticipantHeartbeatResponse>(); heartbeatResponse.BrowserName.Should().Be("chrome"); heartbeatResponse.BrowserVersion.Should().Be("1"); heartbeatResponse.RecentPacketLoss.Should().Be(8); heartbeatResponse.OperatingSystem.Should().Be("Mac OS X"); heartbeatResponse.OperatingSystemVersion.Should().Be("10.15.7"); }
public void TestInitialize() { MockQueryHandler .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>())) .ReturnsAsync(TestConference); }
public MockQueryTest() { _mockService = new MockIOService(); _handler = new MockQueryHandler(_mockService); }