Exemplo n.º 1
0
 public FakeTestComponentSource(FakeComponentInstance fakeComponentInstance)
 {
     _name              = fakeComponentInstance.Name;
     _description       = fakeComponentInstance.Description;
     _factory           = Substitute.For <TestComponentInstanceFactory>();
     _componentInstance = fakeComponentInstance;
     _factory.Create().Returns(_componentInstance);
 }
        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);
        }