コード例 #1
0
        public void Save_WritingSystemIdChanged_ChangeLogUpdated()
        {
            using (var e = new TestEnvironment())
            {
                var repo = LdmlInFolderWritingSystemRepository.Initialize(Path.Combine(e.TestPath, "idchangedtest1"), DummyWritingSystemHandler.onMigration, DummyWritingSystemHandler.onLoadProblem);
                var ws   = WritingSystemDefinition.Parse("en");
                repo.Set(ws);
                repo.Save();

                ws.Script = "Latn";
                repo.Set(ws);
                ws.Script = "Thai";
                repo.Set(ws);

                var ws2 = WritingSystemDefinition.Parse("de");
                repo.Set(ws2);
                ws2.Script = "Latn";
                repo.Save();

                string logFilePath = Path.Combine(repo.PathToWritingSystems, "idchangelog.xml");
                AssertThatXmlIn.File(logFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Change/From[text()='en']");
                AssertThatXmlIn.File(logFilePath).HasAtLeastOneMatchForXpath("/WritingSystemChangeLog/Changes/Change/To[text()='en-Thai']");

                // writing systems added for the first time shouldn't be in the log as a change
                AssertThatXmlIn.File(logFilePath).HasNoMatchForXpath("/WritingSystemChangeLog/Changes/Change/From[text()='de']");
            }
        }
コード例 #2
0
        public void CreateNonExistentWritingSystemsFoundInConfig_FieldsXmlContainsRfcTagThatAfterBeingMadeConformMatchesExistingLdml_LdmlFilesAreLeftUnchanged()
        {
            using (var environment = new TestEnvironment(
                       ConfigFileContentForTests.WrapContentInConfigurationTags(
                           ConfigFileContentForTests.GetConfigFileSnippetContainingFieldWithWritingSystems("en", "audio"))))
            {
                var wsRepo = environment.WritingSystems;

                var enWs = WritingSystemDefinition.Parse("en");
                enWs.Abbreviation = "Dont change me!";
                wsRepo.Set(enWs);
                wsRepo.Save();

                environment.Creator.CreateWritingSystemsForIdsInFileWhereNecassary(environment.WritingSystems);
                AssertThatXmlIn.File(environment.ConfigFilePath).HasAtLeastOneMatchForXpath(
                    "/configuration/components/viewTemplate/fields/field/writingSystems/id[text()='en']");
                AssertThatXmlIn.File(environment.ConfigFilePath).HasAtLeastOneMatchForXpath(
                    "/configuration/components/viewTemplate/fields/field/writingSystems/id[text()='qaa-Zxxx-x-audio']");

                var pathToLdml = Path.Combine(environment.WritingSystemsPath, "en.ldml");
                AssertThatXmlIn.File(pathToLdml).HasAtLeastOneMatchForXpath("/ldml/identity/language[@type='en']");
                AssertThatXmlIn.File(pathToLdml).HasNoMatchForXpath("/ldml/identity/script");
                AssertThatXmlIn.File(pathToLdml).HasNoMatchForXpath("/ldml/identity/territory");
                AssertThatXmlIn.File(pathToLdml).HasNoMatchForXpath("/ldml/identity/variant");
                AssertThatXmlIn.File(pathToLdml).
                HasAtLeastOneMatchForXpath("/ldml/special/palaso:abbreviation[@value='Dont change me!']", environment.NamespaceManager);
            }
        }
コード例 #3
0
        public void SetWritingSystemsForFields_LiftFileContainsWritingsystemNamed_xspec_xspecIsAddedToWritingSystems()
        {
            using (var e = new TestEnvironment())
            {
                e.CreateLiftFile(
                    @"<entry id='foo'>
						<lexical-unit>
							<form lang='x-spec'><text></text></form>
							<form lang='en'><text></text></form>
						</lexical-unit>
					</entry>"                    ,
                    "0.12"
                    );
                var writingSystems = e.WritingSystems;
                writingSystems.Set(WritingSystemDefinition.Parse(WritingSystemsIdsForTests.OtherIdForTest));
                writingSystems.Set(WritingSystemDefinition.Parse(WritingSystemsIdsForTests.AnalysisIdForTest));
                var vt = ViewTemplate.MakeMasterTemplate(writingSystems);
                //put one guy in there already
                int originalCount = writingSystems.Count;                // collection.Count;

                var creator = new ProjectFromLiftFolderCreator(e.LiftFilePath, vt, writingSystems);
                creator.SetWritingSystemsForFields();
                Assert.IsTrue(writingSystems.Contains("x-spec"));
            }
        }
コード例 #4
0
        public void TestAddItem()
        {
            IWritingSystemDefinition ws  = WritingSystemDefinition.Parse("fr");
            IWritingSystemDefinition ws2 = WritingSystemDefinition.Parse("en");
            var listBox = new GeckoListBox();

            listBox.FormWritingSystem    = ws;
            listBox.MeaningWritingSystem = ws2;
            listBox.Name = "ControlUnderTest";
            Assert.IsNotNull(listBox);

            String volvo  = "Volvo";
            String saab   = "Saab";
            String toyota = "Toyota";

            listBox.AddItem(volvo);
            listBox.AddItem(saab);
            listBox.AddItem(toyota);

            Assert.AreSame(saab, listBox.GetItem(1));
            Assert.AreSame(toyota, listBox.GetItem(2));
            Assert.AreEqual(3, listBox.Length);
            Assert.AreSame(ws2, listBox.MeaningWritingSystem);

            listBox.Clear();
            Assert.AreEqual(0, listBox.Length);
        }
コード例 #5
0
        public void Setup()
        {
            _ws = WritingSystemDefinition.Parse("qaa-x-qaa");
            _ws.DefaultFontName = "Arial";
            _ws.DefaultFontSize = (float)55.9;
            //            _createNewClickedFired=false;
            //            _valueChangedFired = false;
            _sourceChoices = new OptionsList();
            _choiceKeys    = new List <string>();
            AddSourceChoice("one", "1", "Notice, this is not the number two.");
            //nb: key 'two' in there
            AddSourceChoice("two", "2", "A description of two which includes the word duo.");
            AddSourceChoice("three",
                            "3",
                            "A description of this which includes the word trio and is not two.");

            _displayAdaptor = new OptionDisplayAdaptor(_sourceChoices, _ws.Id);
            _control        =
                new AutoCompleteWithCreationBox <Option, string>(
                    CommonEnumerations.VisibilitySetting.Visible, null);
            _control.Name             = "autobox";
            _control.Box.Items        = _sourceChoices.Options;
            _control.Box.ItemFilterer = _displayAdaptor.GetItemsToOffer;

            //leave for individual tests _control.CreateNewClicked += new EventHandler<CreateNewArgs>(_control_CreateNewClicked);
            _control.Box.ItemDisplayStringAdaptor = _displayAdaptor;
            _control.Box.WritingSystem            = _ws;
            _control.GetKeyValueFromValue         = _displayAdaptor.GetOptionFromKey;
            _control.GetValueFromKeyValue         = _displayAdaptor.GetKeyFromOption;
            _control.ValueChanged += _control_ValueChanged;

            _dataBeingEditted = new OptionRef();
        }
コード例 #6
0
        public void Setup()
        {
            BasilProjectTestHelper.InitializeForTests();
            _writingSystemId = WritingSystemsIdsForTests.AnalysisIdForTest;

            IWritingSystemDefinition writingSystem = WritingSystemDefinition.Parse(_writingSystemId);

            _papaNameWidget       = new WeSayTextBox(writingSystem, null);
            _papaNameWidget.Text  = "John";
            _ghostFirstNameWidget = new WeSayTextBox(writingSystem, null);
            _binding = new GhostBinding <Child>(null,
                                                _papa.Children,
                                                "First",
                                                writingSystem,
                                                _ghostFirstNameWidget);
            _didNotify = false;
            //Window w = new Window("test");
            //VBox box = new VBox();
            //w.Add(box);
            //box.PackStart(_papaNameWidget);
            //box.PackStart(_ghostFirstNameWidget);
            //box.ShowAll();
            //w.ShowAll();
            _papaNameWidget.Show();
            //            while (Gtk.Application.EventsPending())
            //            { Gtk.Application.RunIteration(); }

            //Application.Run();
            _papaNameWidget.Focus();
            _ghostFirstNameWidget.Focus();
        }
コード例 #7
0
        public void SetWritingSystem_DoesntThrow()
        {
            var textBox = new GeckoComboBox();
            IWritingSystemDefinition ws = WritingSystemDefinition.Parse("fr");

            Assert.DoesNotThrow(() => textBox.WritingSystem = ws);
        }
コード例 #8
0
        public void KeyboardInputWhenReadOnlyTest()
        {
            IWritingSystemDefinition ws      = WritingSystemDefinition.Parse("fr");
            IWeSayTextBox            textBox = new GeckoBox(ws, "ControlUnderTest");

            textBox.ReadOnly = true;
            Assert.IsNotNull(textBox);
            Assert.AreSame(ws, textBox.WritingSystem);
            _window.Controls.Add((GeckoBox)textBox);
            _window.Show();
            ControlTester t = new ControlTester("ControlUnderTest", _window);

            textBox.Text = "Value";
            KeyboardController keyboardController = new KeyboardController(t);

            Application.DoEvents();
            keyboardController.Press(Key.END);
            Application.DoEvents();
            keyboardController.Press(" ");
            keyboardController.Press("T");
            keyboardController.Press("e");
            keyboardController.Press("s");
            keyboardController.Press("t");
            Application.DoEvents();
            Assert.AreEqual("Value", textBox.Text);
            keyboardController.Dispose();
        }
コード例 #9
0
        public void KeyboardInputAfterInitialValueTest()
        {
            IWritingSystemDefinition ws      = WritingSystemDefinition.Parse("fr");
            IWeSayTextBox            textBox = new GeckoBox(ws, "ControlUnderTest");

            Assert.IsNotNull(textBox);
            Assert.AreSame(ws, textBox.WritingSystem);
            _window.Controls.Add((GeckoBox)textBox);
            _window.Show();
            ControlTester t = new ControlTester("ControlUnderTest", _window);

            textBox.Text = "Test";
            KeyboardController keyboardController = new KeyboardController(t);

            Application.DoEvents();
            keyboardController.Press(Key.HOME);
            Application.DoEvents();
            keyboardController.Press("V");
            keyboardController.Press("a");
            keyboardController.Press("l");
            keyboardController.Press("u");
            keyboardController.Press("e");
            keyboardController.Press(" ");
            Application.DoEvents();
            Assert.AreEqual("Value Test", textBox.Text);
            keyboardController.Dispose();
        }
コード例 #10
0
        public void SetWritingSystemsForFields_LiftFileContainsWritingsystemsForWhichThereIsNoDefinition_TellsUser()
        {
            using (var e = new TestEnvironment())
            {
                e.CreateLiftFile(
                    @"<entry id='foo'>
						<lexical-unit>
							<form lang='qaa-x-blah'><text></text></form>
							<form lang='en'><text></text></form>
						</lexical-unit>
					  </entry>"                    ,
                    "0.12"
                    );
                var collection = e.WritingSystems;
                collection.Set(WritingSystemDefinition.Parse(WritingSystemsIdsForTests.OtherIdForTest));
                collection.Set(WritingSystemDefinition.Parse(WritingSystemsIdsForTests.AnalysisIdForTest));
                var vt = ViewTemplate.MakeMasterTemplate(collection);
                //put one guy in there already
                int originalCount = collection.Count;                // collection.Count;

                Assert.IsFalse(collection.Contains("qaa-x-blah"));
                var creator = new ProjectFromLiftFolderCreator(e.LiftFilePath, vt, collection);

                Assert.Throws <ErrorReport.ProblemNotificationSentToUserException>(
                    creator.SetWritingSystemsForFields
                    );

                Assert.IsTrue(collection.Contains("qaa-x-blah"));
            }
        }
コード例 #11
0
ファイル: WritingSystemTests.cs プロジェクト: sillsdev/wesay
        public void SortUsing_CustomSimpleWithNoRules_sortsLikeInvariant()
        {
            var writingSystem = WritingSystemDefinition.Parse("th");

            writingSystem.SortUsingCustomSimple("");
            // hard to test because half of the system locales use the invariant table: http://blogs.msdn.com/michkap/archive/2004/12/29/344136.aspx
        }
コード例 #12
0
        public void Set_NewWritingSystem_EventIsNotFired()
        {
            RepositoryUnderTest.WritingSystemIdChanged += OnWritingSystemIdChanged;
            var ws = WritingSystemDefinition.Parse("en");

            RepositoryUnderTest.Set(ws);
            Assert.That(_writingSystemIdChangedEventArgs, Is.Null);
        }
コード例 #13
0
 public void Remove_TwoWritingSystemsOneIsDeleted_OneWritingSystemRemains()
 {
     RepositoryUnderTest.Set(WritingSystemDefinition.Parse("en"));
     RepositoryUnderTest.Set(WritingSystemDefinition.Parse("de"));
     RepositoryUnderTest.Remove("en");
     Assert.That(RepositoryUnderTest.Contains("de"), Is.True);
     Assert.That(RepositoryUnderTest.Contains("en"), Is.False);
 }
コード例 #14
0
            public IWritingSystemRepository MakeSampleCollection()
            {
                var writingSystemStore = GetWritingSystemRepository(PathToWritingSystemsFolder);

                writingSystemStore.Set(WritingSystemDefinition.Parse("en"));
                writingSystemStore.Set(WritingSystemDefinition.Parse("de"));
                return(writingSystemStore);
            }
コード例 #15
0
        public void Get_FieldNull_Throws()
        {
            Field fieldToFill = null;
            WritingSystemDefinition lexicalFormWritingSystem = WritingSystemDefinition.Parse("de");

            Assert.Throws <ArgumentNullException>(() =>
                                                  _lexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit(fieldToFill, null, lexicalFormWritingSystem));
        }
コード例 #16
0
        public void GeckoBox_CreateWithWritingSystem()
        {
            IWritingSystemDefinition ws      = WritingSystemDefinition.Parse("fr");
            IWeSayTextBox            textBox = new GeckoBox(ws, null);

            Assert.IsNotNull(textBox);
            Assert.AreSame(ws, textBox.WritingSystem);
        }
コード例 #17
0
        private void CreateCaches()
        {
            IWritingSystemDefinition writingSystemToMatch = WritingSystemDefinition.Parse("de");

            _repository.GetAllEntriesSortedByHeadword(writingSystemToMatch);
            _repository.GetAllEntriesSortedByLexicalFormOrAlternative(writingSystemToMatch);
            //_repository.GetAllEntriesSortedByDefinitionOrGloss(writingSystemToMatch);
        }
コード例 #18
0
ファイル: GeckoComboBoxTests.cs プロジェクト: sillsdev/wesay
        public void CreateWithWritingSystem()
        {
            IWritingSystemDefinition ws = WritingSystemDefinition.Parse("fr");
            var comboBox = new GeckoComboBox(ws, null);

            Assert.IsNotNull(comboBox);
            Assert.AreSame(ws, comboBox.WritingSystem);
        }
コード例 #19
0
 public void Conflate_TwoWritingSystemsOneIsConflatedIntoOther_OneWritingSystemRemains()
 {
     RepositoryUnderTest.Set(WritingSystemDefinition.Parse("en"));
     RepositoryUnderTest.Set(WritingSystemDefinition.Parse("de"));
     RepositoryUnderTest.Conflate("en", "de");
     Assert.That(RepositoryUnderTest.Contains("de"), Is.True);
     Assert.That(RepositoryUnderTest.Contains("en"), Is.False);
 }
コード例 #20
0
        public void Get_FieldNameDoesNotExist_ReturnsEmpty()
        {
            Field fieldToFill = new Field("I do not exist!", "LexEntry", new string[] { "fr" });
            WritingSystemDefinition lexicalFormWritingSystem = WritingSystemDefinition.Parse("de");
            ResultSet <LexEntry>    sortedResults            =
                _lexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit(fieldToFill, null, lexicalFormWritingSystem);

            Assert.AreEqual(0, sortedResults.Count);
        }
コード例 #21
0
ファイル: WritingSystemTests.cs プロジェクト: sillsdev/wesay
        public void Compare_en_sortsLikeEnglish()
        {
            var writingSystem = WritingSystemDefinition.Parse("th");

            writingSystem.SortUsingOtherLanguage("en-US");
            //u00c8 is Latin Capital Letter E with Grave
            //u00ed is Latin small letter i with acute
            Assert.Greater(writingSystem.Collator.Compare("\u00c8dit", "Ed\u00edt"), 0);
        }
コード例 #22
0
        public void GeckoListBox_CreateWithWritingSystem()
        {
            IWritingSystemDefinition ws = WritingSystemDefinition.Parse("fr");
            var listBox = new GeckoListBox(ws, null);

            Assert.IsNotNull(listBox);
            Assert.AreSame(ws, listBox.WritingSystem);
            Assert.AreSame(ws, listBox.FormWritingSystem);
        }
コード例 #23
0
        public void Remove_WritingsystemIdExists_FiresEventAndEventArgIsSetToIdOfDeletedWritingSystem()
        {
            RepositoryUnderTest.WritingSystemDeleted += OnWritingsystemDeleted;
            var ws = WritingSystemDefinition.Parse("en");

            RepositoryUnderTest.Set(ws);
            RepositoryUnderTest.Remove(ws.Id);
            Assert.That(_writingSystemDeletedEventArgs.Id, Is.EqualTo(ws.Id));
        }
コード例 #24
0
        public void TestAddItem()
        {
            try
            {
                int    j     = 0;
                String value = "";
                IWritingSystemDefinition ws = WritingSystemDefinition.Parse("fr");
                var comboBox = new GeckoComboBox();
                comboBox.WritingSystem = ws;
                comboBox.Name          = "ControlUnderTest";
                Assert.IsNotNull(comboBox);
                Assert.AreSame(ws, comboBox.WritingSystem);

                String volvo  = "Volvo";
                String saab   = "Saab";
                String toyota = "Toyota";

                comboBox.AddItem(volvo);
                comboBox.AddItem(saab);
                comboBox.AddItem(toyota);
                comboBox.ListCompleted();

                Application.DoEvents();

                _window.Controls.Add((GeckoComboBox)comboBox);
                _window.Show();
                ControlTester      t = new ControlTester("ControlUnderTest", _window);
                KeyboardController keyboardController = new KeyboardController(t);
                Application.DoEvents();

                j = comboBox.Length;
                keyboardController.Press("{DOWN}");
                Application.DoEvents();
                keyboardController.Release("{DOWN}");
                Application.DoEvents();
                value = (String)comboBox.SelectedItem;
                Assert.AreEqual(3, j);
                Assert.AreEqual("Saab", value);
                keyboardController.Press("{DOWN}");
                Application.DoEvents();
                keyboardController.Release("{DOWN}");
                Application.DoEvents();
                value = (String)comboBox.SelectedItem;
                Application.DoEvents();
                Application.DoEvents();

                Assert.AreEqual(3, j);
                Assert.AreEqual("Toyota", value);
            }
            catch (Exception)
            {
                // Team city sometimes throws exception on this test
                // Rather than remove a test that usually works, I am
                // putting this in to allow it to pass when timing problems
                // occur.
            }
        }
コード例 #25
0
ファイル: WritingSystemTests.cs プロジェクト: sillsdev/wesay
        public void SortUsingCustomICU_WithSortRules_SetsSortRulesAndSortUsing()
        {
            const string             rules         = "&n < ng <<< Ng <<< NG";
            IWritingSystemDefinition writingSystem = WritingSystemDefinition.Parse("th");

            writingSystem.SortUsingCustomICU(rules);
            Assert.AreEqual(rules, writingSystem.SortRules);
            Assert.AreEqual(WritingSystemDefinition.SortRulesType.CustomICU, writingSystem.SortUsing);
        }
コード例 #26
0
        public static WeSayWordsProject InitializeForTests()
        {
            WeSayWordsProject project = new WeSayWordsProject();

            try
            {
                File.Delete(WeSayWordsProject.PathToPretendLiftFile);
            }
            catch (Exception) { }
            DirectoryInfo projectDirectory   = Directory.CreateDirectory(Path.GetDirectoryName(WeSayWordsProject.PathToPretendLiftFile));
            string        pathToLdmlWsFolder = BasilProject.GetPathToLdmlWritingSystemsFolder(projectDirectory.FullName);

            if (File.Exists(WeSayWordsProject.PathToPretendWritingSystemPrefs))
            {
                File.Delete(WeSayWordsProject.PathToPretendWritingSystemPrefs);
            }

            if (Directory.Exists(pathToLdmlWsFolder))
            {
                Directory.Delete(pathToLdmlWsFolder, true);
            }

            Palaso.Lift.Utilities.CreateEmptyLiftFile(WeSayWordsProject.PathToPretendLiftFile, "InitializeForTests()", true);

            //setup writing systems
            Directory.CreateDirectory(pathToLdmlWsFolder);
            IWritingSystemRepository wsc = LdmlInFolderWritingSystemRepository.Initialize(
                pathToLdmlWsFolder,
                OnMigrationHandler,
                OnWritingSystemLoadProblem,
                WritingSystemCompatibility.Flex7V0Compatible
                );

            IWritingSystemDefinition _ws1 = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.VernacularIdForTest);

            _ws1.DefaultFontName = "Arial";
            _ws1.DefaultFontSize = 30;
            wsc.Set(_ws1);
            IWritingSystemDefinition _ws2 = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.AnalysisIdForTest);

            _ws2.DefaultFontName = new Font(FontFamily.GenericSansSerif, 12).Name;
            _ws2.DefaultFontSize = new Font(FontFamily.GenericSansSerif, 12).Size;
            wsc.Set(_ws2);
            IWritingSystemDefinition _ws3 = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.OtherIdForTest);

            _ws3.DefaultFontName = "Arial";
            _ws3.DefaultFontSize = 15;
            wsc.Set(_ws3);


            wsc.Save();

            project.SetupProjectDirForTests(WeSayWordsProject.PathToPretendLiftFile);
            project.BackupMaker = null;            //don't bother. Modern tests which might want to check backup won't be using this old approach anyways.
            return(project);
        }
コード例 #27
0
 public void Conflate_ChangelogRecordsChange()
 {
     using (var e = new TestEnvironment())
     {
         e.Collection.Set(WritingSystemDefinition.Parse("de"));
         e.Collection.Set(WritingSystemDefinition.Parse("en"));
         e.Collection.Conflate("de", "en");
         Assert.That(e.Collection.WritingSystemIdHasChangedTo("de"), Is.EqualTo("en"));
     }
 }
コード例 #28
0
        public void Get_FieldExists_DoesNotReturnResultForThatLexEntry()
        {
            CreateLexentryWithLexicalFormButWithoutCitation("de Word1", "de");
            Field fieldToFill = new Field(LexEntry.WellKnownProperties.LexicalUnit, "LexEntry", new string[] { "de" });
            WritingSystemDefinition lexicalFormWritingSystem = WritingSystemDefinition.Parse("de");
            ResultSet <LexEntry>    sortedResults            =
                _lexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit(fieldToFill, null, lexicalFormWritingSystem);

            Assert.AreEqual(0, sortedResults.Count);
        }
コード例 #29
0
        public void OtherKnownWritingSystems_TokPisinAlreadyExists_DoesNotHaveTokPisin()
        {
            var suggestor = new WritingSystemSuggestor();

            var existingWritingSystems = new List <WritingSystemDefinition> {
                WritingSystemDefinition.Parse("tpi")
            };

            Assert.That(suggestor.GetOtherLanguageSuggestions(existingWritingSystems).Any(ws => ws.Label == "Tok Pisin"), Is.False);
        }
コード例 #30
0
ファイル: WritingSystemTests.cs プロジェクト: sillsdev/wesay
        public void Compare_fr_sortsLikeFrench()
        {
            var writingSystem = WritingSystemDefinition.Parse("en");

            writingSystem.SortUsingOtherLanguage("fr");
            //u00c8 is Latin Capital Letter E with Grave
            //u00ed is Latin small letter i with acute

            Assert.Less(writingSystem.Collator.Compare("\u00c8dit", "Ed\u00edt"), 0);
        }