コード例 #1
0
        public async Task SendEquipmentCommand_EquipmentConnected_ReceiveCommandAsEquipment()
        {
            // arrange
            var testDevices = Array.Empty <EquipmentDevice>();

            var(user, equipmentHub) = await ConnectEquipment(testDevices);

            EquipmentCommandDto?commandDto = null;

            equipmentHub.On(EquipmentHubMessages.OnEquipmentCommand, (EquipmentCommandDto dto) => commandDto = dto);

            // act
            var sendDto = new SendEquipmentCommandDto(equipmentHub.ConnectionId, ProducerSource.Mic, null,
                                                      EquipmentCommandType.Enable);

            var result =
                await user.Hub.InvokeAsync <SuccessOrError <Unit> >(nameof(CoreHub.SendEquipmentCommand), sendDto);

            // assert
            AssertSuccess(result);
            await AssertHelper.WaitForAssert(() =>
            {
                Assert.NotNull(commandDto);
                Assert.Equal(sendDto.Action, commandDto !.Action);
                Assert.Equal(sendDto.DeviceId, commandDto.DeviceId);
                Assert.Equal(sendDto.Source, commandDto.Source);
            });
        }
コード例 #2
0
        public async Task <SuccessOrError <Unit> > SendEquipmentCommand(SendEquipmentCommandDto dto)
        {
            var participant = GetContextParticipant();

            return(await GetInvoker()
                   .Create(new SendEquipmentCommandRequest(participant, dto.ConnectionId, dto.Source, dto.DeviceId,
                                                           dto.Action)).ValidateObject(dto).Send());
        }