public void HomographConfiguration_Persist_Saves_WritingSystemAndCustomNumbers()
        {
            var settings = new HomographConfiguration();

            settings.CustomHomographNumbers = new List <string> {
                "a", "b", "c"
            };
            settings.WritingSystem = "fr";
            var persistanceString = settings.PersistData;

            Assert.That(persistanceString, Is.StringContaining("ws:fr"));
            Assert.That(persistanceString, Is.StringContaining("customHn:a;b;c"));
        }
        public void HomographConfiguration_Persist_Restores_WritingSystemAndCustomNumbers()
        {
            const string oldConfigString = "ws:en customHn:1;2;3;4;00";
            var          settings        = new HomographConfiguration();

            Assert.IsTrue(string.IsNullOrEmpty(settings.WritingSystem));
            CollectionAssert.IsEmpty(settings.CustomHomographNumbers);
            settings.PersistData = oldConfigString;
            Assert.AreEqual("en", settings.WritingSystem);
            CollectionAssert.AreEqual(new List <string> {
                "1", "2", "3", "4", "00"
            }, settings.CustomHomographNumbers);
        }
Esempio n. 3
0
        public void PersistData()
        {
            var hc = new HomographConfiguration();

            Assert.That(hc.PersistData, Is.EqualTo(""));
            hc.HomographNumberBefore = true;
            hc.ShowSenseNumberRef    = false;
            Assert.That(hc.PersistData, Is.EqualTo("before snRef "));
            var hc2 = new HomographConfiguration();

            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowSenseNumberRef, Is.False);
            Assert.That(hc2.HomographNumberBefore, Is.True);
            Assert.That(hc2.ShowSenseNumberReversal, Is.True);

            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.Main, false);
            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main), Is.False);
            Assert.That(hc2.HomographNumberBefore, Is.False);

            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.Main, true);
            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef, false);
            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main), Is.True);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef), Is.False);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef), Is.True);

            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef, false);
            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main), Is.True);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef), Is.False);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef), Is.False);

            hc.SetShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef, true);
            hc2.PersistData = hc.PersistData;
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main), Is.True);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef), Is.True);
            Assert.That(hc2.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef), Is.False);

            hc.ShowSenseNumberRef      = true;
            hc.ShowSenseNumberReversal = false;
            hc2.PersistData            = hc.PersistData;
            Assert.That(hc2.ShowSenseNumberRef, Is.True);
            Assert.That(hc2.ShowSenseNumberReversal, Is.False);
        }
        public void HomographConfiguration_Persist_RestoresOldConfig()
        {
            // property string settings which set homograph to before, turn off the dictionary cross reference(hn:dcr),
            // turn off the reversal cross reference(hn:rcr), turn off show sense number in both dictionary and reversal
            const string oldConfigString = "before hn:dcr hn:rcr snRef snRev";
            var          settings        = new HomographConfiguration();

            Assert.IsFalse(settings.HomographNumberBefore);
            Assert.IsTrue(settings.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef));
            Assert.IsTrue(settings.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef));
            Assert.IsTrue(settings.ShowSenseNumberRef);
            Assert.IsTrue(settings.ShowSenseNumberReversal);
            settings.PersistData = oldConfigString;
            Assert.IsTrue(settings.HomographNumberBefore);
            Assert.IsFalse(settings.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef));
            Assert.IsFalse(settings.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef));
            Assert.IsFalse(settings.ShowSenseNumberRef);
            Assert.IsFalse(settings.ShowSenseNumberReversal);
        }
Esempio n. 5
0
 /// <summary>
 /// It's convenient to test pretty much all these functions with one set of data.
 /// </summary>
 ///
 public override void FixtureSetup()
 {
     base.FixtureSetup();
     m_wsVern     = Cache.DefaultVernWs;
     m_wsAnalysis = Cache.DefaultAnalWs;
     m_hc         = Cache.ServiceLocator.GetInstance <HomographConfiguration>();
     UndoableUnitOfWorkHelper.Do("undoit", "redoit", m_actionHandler,
                                 () =>
     {
         m_kick                    = MakeEntry("kick", "strike with foot");
         m_kickS1                  = m_kick.SensesOS[0];
         m_rightCorrect            = MakeEntry("right", "correct");
         m_rightCorrectS2          = MakeSense(m_rightCorrect, "morally perfect");
         m_rightCorrectSubSense    = MakeSense(m_rightCorrectS2, "test");
         m_rightCorrectSubSubSense = MakeSense(m_rightCorrectSubSense, "test");
         m_rightDirection          = MakeEntry("right", "turn right");
         m_rightDirectionS1        = m_rightDirection.SensesOS[0];
     });
 }