private void SegmentsDataGrid_OnSelectionChanged(object sender, DataGridSelectionChangedEventArgs e)
        {
            if (_selectMonitor.Busy)
            {
                return;
            }

            using (_selectMonitor.Enter())
            {
                var vm = (SegmentMappingsTableViewModel)DataContext;
                if (SegmentsDataGrid.SelectedCellRanges.Count == 1)
                {
                    SelectionCellRange cellRange = SegmentsDataGrid.SelectedCellRanges[0];
                    int itemIndex   = cellRange.ItemRange.StartIndex;
                    var segment     = (SegmentMappingsTableSegmentViewModel)SegmentsDataGrid.Items[itemIndex];
                    int columnIndex = cellRange.ColumnRange.StartIndex;
                    SegmentMappingsTableSegmentPairViewModel segmentPair = segment.SegmentPairs[columnIndex - 1];
                    vm.SelectedSegmentPair = segmentPair.IsEnabled ? segmentPair : null;
                }
                else
                {
                    vm.SelectedSegmentPair = null;
                }
            }
        }
            public TestEnvironment()
            {
                DispatcherHelper.Initialize();
                _projectService = Substitute.For <IProjectService>();
                var dialogService = Substitute.For <IDialogService>();
                var importService = Substitute.For <IImportService>();

                SegmentMappingViewModel.Factory    mappingFactory    = (segment1, segment2) => new SegmentMappingViewModel(_projectService, segment1, segment2);
                NewSegmentMappingViewModel.Factory newMappingFactory = () => new NewSegmentMappingViewModel(_projectService);

                var segmentMappings = new SegmentMappingsViewModel(dialogService, importService, mappingFactory, newMappingFactory);

                _segmentPair = new SegmentMappingsTableSegmentPairViewModel(segmentMappings, mappingFactory,
                                                                            new SegmentMappingsTableSegmentViewModel(new Segment(FeatureStruct.New().Symbol(CogFeatureSystem.ConsonantType).Feature(CogFeatureSystem.StrRep).EqualTo("b").Value), SoundType.Consonant),
                                                                            new SegmentMappingsTableSegmentViewModel(new Segment(FeatureStruct.New().Symbol(CogFeatureSystem.ConsonantType).Feature(CogFeatureSystem.StrRep).EqualTo("c").Value), SoundType.Consonant),
                                                                            100, true);

                var project = new CogProject();

                _projectService.Project.Returns(project);
            }