public async Task Gets_VirtualStudio_data_with_a_connection()
        {
            var placeholder1 = new PlaceholderStudioComponent();

            placeholder1.AddInput("Input 1", DataKind.Audio, "WebRtc");
            var placeholder2 = new PlaceholderStudioComponent();

            placeholder2.AddOutput("Output 1", DataKind.Audio, "WebRtc");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder1);
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder2);
            var nodePosition   = new Position2D(23, 45);
            var componentNode1 = virtualStudio.AddComponent(placeholder1, nodePosition);
            var componentNode2 = virtualStudio.AddComponent(placeholder2, nodePosition);
            var connection     = virtualStudio.CreateConnection(componentNode2.Component.Outputs[0], componentNode1.Component.Inputs[0]);

            var getVirtualStudioQuery = new GetVirtualStudioWithArrangementQuery();
            var virtualStudioDto      = await getVirtualStudioQuery.Process(virtualStudio);

            Assert.IsTrue(virtualStudioDto.Connections.Count() == 1);
            var connectionDto = virtualStudioDto.Connections.First();

            Assert.AreEqual(connection.Id, connectionDto.Id);
            Assert.AreEqual(connection.Input.Id, connectionDto.InputId);
            Assert.AreEqual(connection.Input.Component.Id, connectionDto.InputComponentId);
            Assert.AreEqual(connection.Output.Id, connectionDto.OutputId);
            Assert.AreEqual(connection.Output.Component.Id, connectionDto.OutputComponentId);
            Assert.AreEqual(connection.State, connectionDto.State);
        }
        public async Task Adds_a_PlaceholderComponent_to_the_ComponentRepository()
        {
            var placeholderComponent = new PlaceholderStudioComponent();

            placeholderComponent.SetName("New Placeholder");
            placeholderComponent.AddInput("Input 1", DataKind.Video, "WebRtc");
            placeholderComponent.AddOutput("Output 1", DataKind.Video, "WebRtc");

            var addPlaceholderToRepositoryCommand = new AddPlaceholderToRepositoryCommand(placeholderComponent.ToDto());
            await addPlaceholderToRepositoryCommand.Process(virtualStudio);

            Assert.IsTrue(virtualStudio.ComponentRepository.Placeholders.Count == 1);
            var addedPlaceholder = virtualStudio.ComponentRepository.Placeholders.First();

            Assert.AreEqual(placeholderComponent.Name, addedPlaceholder.Name);
            Assert.AreEqual(placeholderComponent.Inputs.Count, addedPlaceholder.Inputs.Count);
            Assert.AreEqual(placeholderComponent.Outputs.Count, addedPlaceholder.Outputs.Count);
            Assert.AreEqual(placeholderComponent.Inputs[0].Id, addedPlaceholder.Inputs[0].Id);
            Assert.AreEqual(placeholderComponent.Inputs[0].Name, addedPlaceholder.Inputs[0].Name);
            Assert.AreEqual(placeholderComponent.Inputs[0].IOType, addedPlaceholder.Inputs[0].IOType);
            Assert.AreEqual(placeholderComponent.Inputs[0].DataKind, addedPlaceholder.Inputs[0].DataKind);
            Assert.AreEqual(placeholderComponent.Inputs[0].ConnectionType, addedPlaceholder.Inputs[0].ConnectionType);
            Assert.AreEqual(placeholderComponent.Outputs[0].Id, addedPlaceholder.Outputs[0].Id);
            Assert.AreEqual(placeholderComponent.Outputs[0].Name, addedPlaceholder.Outputs[0].Name);
            Assert.AreEqual(placeholderComponent.Outputs[0].IOType, addedPlaceholder.Outputs[0].IOType);
            Assert.AreEqual(placeholderComponent.Outputs[0].DataKind, addedPlaceholder.Outputs[0].DataKind);
            Assert.AreEqual(placeholderComponent.Outputs[0].ConnectionType, addedPlaceholder.Outputs[0].ConnectionType);
        }
        public void TestInit()
        {
            var virtualStudio = new VirtualStudioWithArrangement();

            // Create a placeholder and add it to ComponentRepository and add a copy to the VirtualStudio's components.
            placeholderInRepository = new PlaceholderStudioComponent();
            placeholderInRepository.SetName("Placeholder 1");
            placeholderInRepository.AddInput("Input 1", Shared.DataKind.Audio, "WebRTC");
            placeholderInRepository.AddOutput("Output 1", Shared.DataKind.Audio, "WebRTC");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholderInRepository);
            placeholderInComponents = virtualStudio.AddComponent(placeholderInRepository);

            // Create a component mock and add it to ComponentRepository AND the VirtualStudio.
            client1Mock = new Mock <IStudioComponent>();
            client1Mock.Setup(m => m.SetId(It.IsAny <int>())).Callback <int>((value) => client1Id = value);
            client1Mock.SetupGet(m => m.Id).Returns(() => client1Id);
            virtualStudio.ComponentRepository.AddClient(client1Mock.Object);
            virtualStudio.AddComponent(client1Mock.Object);

            // Create a component mock and add it only to ComponentRepository.
            client2Mock = new Mock <IStudioComponent>();
            client2Mock.Setup(m => m.SetId(It.IsAny <int>())).Callback <int>((value) => client2Id = value);
            client2Mock.SetupGet(m => m.Id).Returns(() => client2Id);
            virtualStudio.ComponentRepository.AddClient(client2Mock.Object);

            this.virtualStudio = virtualStudio;

            operationHandlerMock        = new Mock <IVirtualStudioUpdateListener>();
            virtualStudioEventProcessor = new VirtualStudioEventProcessor(virtualStudio, virtualStudioName, operationHandlerMock.Object);
        }
 public void Init()
 {
     virtualStudio           = new VirtualStudio();
     placeholderInRepository = new PlaceholderStudioComponent();
     placeholderInRepository.SetName("New Placeholder");
     placeholderInRepository.AddOutput("Output 1", DataKind.Data, "hgdfhgoid");
     virtualStudio.ComponentRepository.AddPlaceholder(placeholderInRepository);
     placeholderInComponents = virtualStudio.AddComponent(placeholderInRepository) as PlaceholderStudioComponent;
 }
        public void Init()
        {
            virtualStudio = new VirtualStudio();

            var placeholder = new PlaceholderStudioComponent();

            placeholder.AddInput("Input 1", DataKind.Audio, "UDP");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder);
            componentWithUdpAudioInput = virtualStudio.AddComponent(placeholder);

            placeholder = new PlaceholderStudioComponent();
            placeholder.AddOutput("Output 1", DataKind.Audio, "UDP");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder);
            componentWithUdpAudioOutput = virtualStudio.AddComponent(placeholder);

            connection = virtualStudio.CreateConnection(componentWithUdpAudioOutput.Outputs[0], componentWithUdpAudioInput.Inputs[0]);
        }
Esempio n. 6
0
        private bool ProcessSync(VirtualStudio virtualStudio)
        {
            var placeholder = new PlaceholderStudioComponent();

            placeholder.SetName(component.Name);

            foreach (var input in component.Inputs)
            {
                placeholder.AddInput(input.Name, input.DataKind, input.ConnectionType);
            }
            foreach (var output in component.Outputs)
            {
                placeholder.AddOutput(output.Name, output.DataKind, output.ConnectionType);
            }

            return(virtualStudio.ComponentRepository.AddPlaceholder(placeholder));
        }
Esempio n. 7
0
        public void Init()
        {
            virtualStudio = new VirtualStudio();

            var placeholder = new PlaceholderStudioComponent();

            placeholder.AddInput("Input 1", DataKind.Audio, "UDP");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder);
            componentWithUdpAudioInput             = virtualStudio.AddComponent(placeholder);
            componentWithUdpAudioInputInRepository = placeholder;

            placeholder = new PlaceholderStudioComponent();
            placeholder.AddInput("Input 1", DataKind.Audio, "WebRtc");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder);
            componentWithWebRtcAudioInput = virtualStudio.AddComponent(placeholder);

            placeholder = new PlaceholderStudioComponent();
            placeholder.AddInput("Input 1", DataKind.Video, "WebRtc");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder);
            componentWithWebRtcVideoInput = virtualStudio.AddComponent(placeholder);

            placeholder = new PlaceholderStudioComponent();
            placeholder.AddOutput("Output 1", DataKind.Audio, "UDP");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder);
            componentWithUdpAudioOutput = virtualStudio.AddComponent(placeholder);

            placeholder = new PlaceholderStudioComponent();
            placeholder.AddOutput("Output 1", DataKind.Audio, "WebRtc");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder);
            componentWithWebRtcAudioOutput = virtualStudio.AddComponent(placeholder);

            placeholder = new PlaceholderStudioComponent();
            placeholder.AddOutput("Output 1", DataKind.Video, "WebRtc");
            virtualStudio.ComponentRepository.AddPlaceholder(placeholder);
            componentWithWebRtcVideoOutput = virtualStudio.AddComponent(placeholder);
        }