Exemplo n.º 1
0
        public void Save_SetsModelContents()
        {
            var testConfig = new DictionaryHomographConfiguration
            {
                HomographNumberBefore = true,
                ShowHwNumInCrossRef   = false,
                ShowSenseNumber       = false,
            };
            var view = new TestHeadwordNumbersView {
                HomographBefore = false, ShowHomograph = true, ShowSenseNumber = true
            };
            var model = new DictionaryConfigurationModel {
                HomographConfiguration = testConfig
            };
            // ReSharper disable once UnusedVariable
            var testController = new HeadwordNumbersController(view, model, Cache);

            view.Show();
            view.HomographBefore         = false;
            view.ShowHomographOnCrossRef = true;
            view.ShowSenseNumber         = true;
            // SUT
            testController.Save();
            // Verify save in Dictionary Config
            Assert.IsFalse(model.HomographConfiguration.HomographNumberBefore);
            Assert.IsTrue(model.HomographConfiguration.ShowHwNumInCrossRef);
            Assert.IsTrue(model.HomographConfiguration.ShowSenseNumber);
        }
Exemplo n.º 2
0
 public HeadwordNumbersController(IHeadwordNumbersView view, DictionaryConfigurationModel model, LcmCache cache)
 {
     if (view == null || model == null || cache == null)
     {
         throw new ArgumentNullException();
     }
     _view             = view;
     _model            = model;
     _cache            = cache;
     _homographConfig  = GetHeadwordConfiguration();
     _view.Description = string.Format(xWorksStrings.ConfigureHomograph_ConfigDescription,
                                       model.IsReversal ? xWorksStrings.ReversalIndex : xWorksStrings.Dictionary,
                                       Environment.NewLine,
                                       model.Label);
     _view.SetWsFactoryForCustomDigits(cache.WritingSystemFactory);
     _view.AvailableWritingSystems = cache.LangProject.CurrentAnalysisWritingSystems.Union(cache.LangProject.CurrentVernacularWritingSystems);
     _view.CustomDigits            = _homographConfig.CustomHomographNumberList;
     if (_cache.LangProject.AllWritingSystems.Any(ws => ws.Id == _homographConfig.HomographWritingSystem))
     {
         _view.HomographWritingSystem = string.IsNullOrEmpty(_homographConfig.HomographWritingSystem)
                                 ? null
                                 : _cache.LangProject.AllWritingSystems.First(ws => ws.Id == _homographConfig.HomographWritingSystem).DisplayLabel;
     }
     else
     {
         _view.HomographWritingSystem = _cache.LangProject.AllWritingSystems.First().DisplayLabel;
     }
     _view.HomographBefore         = _homographConfig.HomographNumberBefore;
     _view.ShowHomograph           = _homographConfig.ShowHwNumber;
     _view.ShowHomographOnCrossRef = _model.IsReversal ? _homographConfig.ShowHwNumInReversalCrossRef : _homographConfig.ShowHwNumInCrossRef;
     _view.ShowSenseNumber         = _model.IsReversal ? _homographConfig.ShowSenseNumberReversal : _homographConfig.ShowSenseNumber;
     _view.OkButtonEnabled         = _homographConfig.CustomHomographNumberList == null ||
                                     !_homographConfig.CustomHomographNumberList.Any() || _homographConfig.CustomHomographNumberList.Count == 10;
     _view.CustomDigitsChanged += OnViewCustomDigitsChanged;
 }
Exemplo n.º 3
0
        public void ViewReflectsModelContents_Reversal()
        {
            var testConfig = new DictionaryHomographConfiguration
            {
                HomographNumberBefore       = true,
                ShowHwNumInReversalCrossRef = false,
                ShowSenseNumberReversal     = false
            };
            var view  = new TestHeadwordNumbersView();
            var model = new DictionaryConfigurationModel {
                WritingSystem = "en", HomographConfiguration = testConfig
            };
            // ReSharper disable once UnusedVariable
            var testController = new HeadwordNumbersController(view, model, Cache);

            view.Show();
            Assert.IsTrue(view.HomographBefore);
            Assert.IsFalse(view.ShowHomographOnCrossRef);
            Assert.IsFalse(view.ShowSenseNumber);
        }