public void Should_throw_conference_not_found_exception_when_conference_does_not_exist()
        {
            var conferenceId  = Guid.NewGuid();
            var participantId = Guid.NewGuid();
            var command       = new UpdateSelfTestCallResultCommand(conferenceId, participantId, true, TestScore.Good);

            Assert.ThrowsAsync <ConferenceNotFoundException>(() => _handler.Handle(command));
        }
        public async Task Should_throw_participant_not_found_exception_when_participant_does_not_exist()
        {
            var seededConference = await TestDataManager.SeedConference();

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;
            var participantId = Guid.NewGuid();
            var command       = new UpdateSelfTestCallResultCommand(_newConferenceId, participantId, true, TestScore.Good);

            Assert.ThrowsAsync <ParticipantNotFoundException>(() => _handler.Handle(command));
        }
示例#3
0
        public async Task should_return_okay_with_response()
        {
            var testResult = Builder <TestCallResult> .CreateNew()
                             .WithFactory(() => new TestCallResult(true, TestScore.Good)).Build();

            MockVideoPlatformService
            .Setup(x => x.GetTestCallScoreAsync(It.IsAny <Guid>(), It.IsAny <int>()))
            .Returns(Task.FromResult(testResult));

            var conferenceId  = Guid.NewGuid();
            var participantId = Guid.NewGuid();
            var command       =
                new UpdateSelfTestCallResultCommand(conferenceId, participantId, testResult.Passed, testResult.Score);

            MockCommandHandler.Setup(x => x.Handle(command));

            var response = await Controller.GetTestCallResultForParticipantAsync(Guid.NewGuid(), Guid.NewGuid());

            var typedResult = (OkObjectResult)response;

            typedResult.Should().NotBeNull();
        }
示例#4
0
        public async Task <IActionResult> GetTestCallResultForParticipantAsync(Guid conferenceId, Guid participantId)
        {
            _logger.LogDebug("GetTestCallResultForParticipant");

            var testCallResult = await _videoPlatformService.GetTestCallScoreAsync(participantId);

            if (testCallResult == null)
            {
                _logger.LogWarning("Unable to find test call result");
                return(NotFound());
            }

            var command = new UpdateSelfTestCallResultCommand(conferenceId, participantId, testCallResult.Passed, testCallResult.Score);

            await _commandHandler.Handle(command);

            _logger.LogDebug("Saving test call result");

            var response = TaskCallResultResponseMapper.MapTaskToResponse(testCallResult);

            return(Ok(response));
        }
        public async Task Should_update_participant_self_test_score()
        {
            var seededConference = await TestDataManager.SeedConference();

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;
            var participantId = seededConference.Participants.First().Id;
            var command       = new UpdateSelfTestCallResultCommand(_newConferenceId, participantId, true, TestScore.Good);

            await _handler.Handle(command);

            Conference resultConference;

            await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                resultConference = await db.Conferences.Include(x => x.Participants).ThenInclude(x => x.TestCallResult)
                                   .SingleAsync(x => x.Id == command.ConferenceId);
            }

            var resultParticipant = resultConference.GetParticipants().Single(x => x.Id == participantId);

            resultParticipant.TestCallResult.Passed.Should().BeTrue();
            resultParticipant.TestCallResult.Score.Should().Be(TestScore.Good);
        }