예제 #1
0
        protected override Task PublishStatusAsync(CallbackEvent callbackEvent)
        {
            var participantState = ParticipantState.Joining;
            var command          = new UpdateParticipantStatusCommand(SourceConference.Id, SourceParticipant.Id, participantState);

            return(CommandHandler.Handle(command));
        }
        public async Task Should_send_not_signed_in_message_to_participants_and_service_bus_when_a_participant_is_not_signed_in()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);

            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.ParticipantNotSignedIn,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                ParticipantId = participantForEvent.Id,
                TimeStampUtc  = DateTime.UtcNow
            };
            var updateStatusCommand = new UpdateParticipantStatusCommand(conference.Id, participantForEvent.Id,
                                                                         ParticipantState.NotSignedIn);

            CommandHandlerMock.Setup(x => x.Handle(updateStatusCommand));

            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusCommand>(command =>
                                                                     command.ConferenceId == conference.Id &&
                                                                     command.ParticipantId == participantForEvent.Id &&
                                                                     command.ParticipantState == ParticipantState.NotSignedIn)), Times.Once);
        }
        public void Should_throw_conference_not_found_exception_when_conference_does_not_exist()
        {
            var conferenceId  = Guid.NewGuid();
            var participantId = Guid.NewGuid();
            var state         = ParticipantState.InConsultation;
            var command       = new UpdateParticipantStatusCommand(conferenceId, participantId, state);

            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 state         = ParticipantState.InConsultation;
            var command       = new UpdateParticipantStatusCommand(_newConferenceId, participantId, state);

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

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;
            var participant = seededConference.GetParticipants().First();
            const ParticipantState state = ParticipantState.InConsultation;

            var beforeState = participant.GetCurrentStatus();

            var command = new UpdateParticipantStatusCommand(_newConferenceId, participant.Id, state);
            await _handler.Handle(command);

            var updatedConference = await _conferenceByIdHandler.Handle(new GetConferenceByIdQuery(_newConferenceId));

            var updatedParticipant = updatedConference.GetParticipants().Single(x => x.Username == participant.Username);
            var afterState         = updatedParticipant.GetCurrentStatus();

            afterState.Should().NotBe(beforeState);
            afterState.ParticipantState.Should().Be(state);
        }