Esempio n. 1
0
        public MainController(
            IObservable<EventType> environmentEvents1,
            IFactory<OptionsController> optionsController,
            MainViewModel viewModel,
            ContinuousConfigurator continuousConfigurator,
            IOptionsManager optionsManager,
            IHostEnviromentConnection host,
            CommonServices svc)
        {
            _optionsController = optionsController;
            _viewModel = viewModel;
            _continuousConfigurator = continuousConfigurator;
            _optionsManager = optionsManager;
            _host = host;
            _sessionFinished = new Subject<string>();
            _controlSource = new Subject<ControlEvent>();
            _svc = svc;

            _viewModel.CommandCreateNewMutants = new SmartCommand(() => RunMutationSession(),
                () => _viewModel.OperationsState.IsIn(OperationsState.None, OperationsState.Finished, OperationsState.Error))
                .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandPause = new SmartCommand(PauseOperations, 
                () => _viewModel.OperationsState.IsIn(OperationsState.Testing))
                .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandStop = new SmartCommand(StopOperations,
                () => _viewModel.OperationsState.IsIn(OperationsState.Mutating, OperationsState.PreCheck,
                    OperationsState.Testing, OperationsState.TestingPaused, OperationsState.Pausing))
                .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandContinue = new SmartCommand(ResumeOperations,
                () => _viewModel.OperationsState == OperationsState.TestingPaused)
                .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandSaveResults = new SmartCommand(SaveResults, () =>
                _viewModel.OperationsState == OperationsState.Finished)
                .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandOptions = new SmartCommand(() => ShowOptions(),
                () => _viewModel.OperationsState.IsIn(OperationsState.None, OperationsState.Finished, OperationsState.Error))
                .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);
            _viewModel.CommandTest = new SmartCommand(Test);


            _disp = new List<IDisposable>
                    {
                        environmentEvents1
                            .Where(e => e == EventType.HostOpened)
                            .Subscribe(type =>
                            {
                                Initialize();
                                continuousConfigurator.CreateConfiguration();
                            }),
                        environmentEvents1
                            .Where(e => e == EventType.HostClosed)
                            .Subscribe(type =>
                            {
                                continuousConfigurator.DisposeConfiguration();
                                Deactivate();
                            }),
                        environmentEvents1
                            .Where(e => e == EventType.BuildBegin)
                            .Subscribe(type => continuousConfigurator.DisposeConfiguration()),

                        environmentEvents1
                            .Where(e => e == EventType.BuildDone)
                            .Subscribe(type => continuousConfigurator.CreateConfiguration()),

                        _optionsManager.Events
                            .Where(e => e == OptionsManager.EventType.Updated)
                            .Subscribe(t =>
                            {
                                continuousConfigurator.DisposeConfiguration();
                                continuousConfigurator.CreateConfiguration();
                            }),
                    };

        }
Esempio n. 2
0
        public MainController(
            IObservable <EventType> environmentEvents1,
            IFactory <OptionsController> optionsController,
            MainViewModel viewModel,
            ContinuousConfigurator continuousConfigurator,
            IOptionsManager optionsManager,
            IHostEnviromentConnection host,
            CommonServices svc)
        {
            _optionsController      = optionsController;
            _viewModel              = viewModel;
            _continuousConfigurator = continuousConfigurator;
            _optionsManager         = optionsManager;
            _host            = host;
            _sessionFinished = new Subject <string>();
            _controlSource   = new Subject <ControlEvent>();
            _svc             = svc;

            _viewModel.CommandCreateNewMutants = new SmartCommand(() => RunMutationSession(),
                                                                  () => _viewModel.OperationsState.IsIn(OperationsState.None, OperationsState.Finished, OperationsState.Error))
                                                 .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandPause = new SmartCommand(PauseOperations,
                                                       () => _viewModel.OperationsState.IsIn(OperationsState.Testing))
                                      .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandStop = new SmartCommand(StopOperations,
                                                      () => _viewModel.OperationsState.IsIn(OperationsState.Mutating, OperationsState.PreCheck,
                                                                                            OperationsState.Testing, OperationsState.TestingPaused, OperationsState.Pausing))
                                     .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandContinue = new SmartCommand(ResumeOperations,
                                                          () => _viewModel.OperationsState == OperationsState.TestingPaused)
                                         .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandSaveResults = new SmartCommand(SaveResults, () =>
                                                             _viewModel.OperationsState == OperationsState.Finished)
                                            .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);

            _viewModel.CommandOptions = new SmartCommand(() => ShowOptions(),
                                                         () => _viewModel.OperationsState.IsIn(OperationsState.None, OperationsState.Finished, OperationsState.Error))
                                        .UpdateOnChanged(_viewModel, () => _viewModel.OperationsState);
            _viewModel.CommandTest = new SmartCommand(Test);

            _disp = new List <IDisposable>
            {
                environmentEvents1
                .Where(e => e == EventType.HostOpened)
                .Subscribe(type =>
                {
                    Initialize();
                    continuousConfigurator.CreateConfiguration();
                }),
                environmentEvents1
                .Where(e => e == EventType.HostClosed)
                .Subscribe(type =>
                {
                    continuousConfigurator.DisposeConfiguration();
                    Deactivate();
                }),
                environmentEvents1
                .Where(e => e == EventType.BuildBegin)
                .Subscribe(type => continuousConfigurator.DisposeConfiguration()),

                environmentEvents1
                .Where(e => e == EventType.BuildDone)
                .Subscribe(type => continuousConfigurator.CreateConfiguration()),

                _optionsManager.Events
                .Where(e => e == OptionsManager.EventType.Updated)
                .Subscribe(t =>
                {
                    continuousConfigurator.DisposeConfiguration();
                    continuousConfigurator.CreateConfiguration();
                }),
            };
        }