public AddComponentInstanceCommand(
     ComponentInstancesViewModel componentInstancesViewModel,
     ComponentInstanceViewModelFactory componentInstanceViewModelFactory,
     TestComponentViewModel testComponentViewModel)
 {
     _componentInstancesViewModel       = componentInstancesViewModel;
     _componentInstanceViewModelFactory = componentInstanceViewModelFactory;
     _testComponentViewModel            = testComponentViewModel;
 }
        public ComponentInstanceViewModel CreateComponentInstanceViewModel(TestComponentViewModel testComponentViewModel)
        {
            var testComponentInstance   = _componentInstanceFactory.Create();
            var nullCapabilities        = new NullCapabilities();
            var interfaceCasts          = new InterfaceCasts(testComponentInstance);
            var customGuiCapability     = interfaceCasts.To <Capabilities.CustomGui>(nullCapabilities);
            var customClosingCapability = interfaceCasts.To <Capabilities.CleanupOnEnvironmentClosing>(nullCapabilities);

            _applicationEvents.EnvironmentClosing += customClosingCapability.CleanupOnClosing;

            var componentInstanceViewModel
                = new ComponentInstanceViewModel(
                      GenerateInstanceName(testComponentViewModel),
                      _outputFactory,
                      new OperationEntries(_backgroundTasks),
                      testComponentInstance,
                      _backgroundTasks,
                      _operationMachinesByControlObject, customGuiCapability);

            componentInstanceViewModel.Initialize(_operationViewModelFactory);

            return(componentInstanceViewModel);
        }
 private string GenerateInstanceName(TestComponentViewModel testComponentViewModel)
 {
     return(testComponentViewModel.Name + id++);
 }
 public FakeTestComponent(TestComponentViewModel testComponentViewModel)
 {
     _testComponentViewModel = testComponentViewModel;
 }