コード例 #1
0
        public void Initialize()
        {
            _viewModel = CreateViewModel();
            _container.RegisterInstance(_viewModel);

            var region = _regionManager.Regions[RegionNames.MainContent];
            var view = _container.Resolve<TestResultsView>();

            region.Add(view);
            region.Activate(view);

            _eventAggregator.GetEvent<ShowTestResultsEvent>().Subscribe(arg => region.Activate(view), ThreadOption.UIThread, true);
        }
コード例 #2
0
        private TestResultsViewModel CreateViewModel()
        {
            var viewModel = new TestResultsViewModel
                {
                    ShowPassed = true,
                    ShowFailed = true,
                    IsRunning = false,
                };
            _testResultsViews = new List<ICollectionView>();

            List<DriverType> enabledBrowsers;

            try
            {
                // TODO: Create a settings service and store the client browser settings there.
                enabledBrowsers = JsonConvert.DeserializeObject<List<DriverType>>(_settingsService.GetEnabledBrowsers())
                    ?? new List<DriverType> { DriverType.PhantomJs };
            }
            catch
            {
                enabledBrowsers = new List<DriverType> { DriverType.PhantomJs };
            }

            foreach (var browser in enabledBrowsers)
            {
                switch (browser)
                {
                    case DriverType.PhantomJs:
                        viewModel.UsePhantomJs = true;
                        break;

                    case DriverType.Firefox:
                        viewModel.UseFirefox = true;
                        break;

                    case DriverType.Chrome:
                        viewModel.UseChrome = true;
                        break;

                    case DriverType.InternetExplorer:
                        viewModel.UseInternetExplorer = true;
                        break;
                }
            }

            viewModel.RunTestsCommand = new DelegateCommand(RunTests, () => AnyBrowserEnabled && !_viewModel.IsRunning);
            viewModel.CancelTestRunCommand = new DelegateCommand(CancelTestRun, () => viewModel.IsRunning && !_isCancelRequested);
            viewModel.ExportToClipboardCommand = new DelegateCommand(ExportToClipboard, () => !_viewModel.IsRunning);

            viewModel.EnabledBrowsersChangedCommand = new DelegateCommand(SaveEnabledBrowsers);
            viewModel.TestResultsFilterChangedCommand = new DelegateCommand(UpdateFilters);

            return viewModel;
        }
コード例 #3
0
        public TestResultsView(TestResultsViewModel viewModel)
        {
            InitializeComponent();

            DataContext = viewModel;
        }