Esempio n. 1
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);
        }