Exemple #1
0
        public void Varieties_DomainModelChangedMessage_CheckForErrors()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                var project = new CogProject(env.SpanFactory);
                env.OpenProject(project);

                project.Meanings.Add(new Meaning("gloss1", "cat1"));
                var bat = new Word("bat", project.Meanings[0]);
                project.Varieties.Add(new Variety("variety1")
                {
                    Words = { bat }
                });

                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.False);

                var segmenter = new Segmenter(env.SpanFactory)
                {
                    Consonants = { "b", "t" },
                    Vowels     = { "a" }
                };
                segmenter.Segment(bat);

                Messenger.Default.Send(new DomainModelChangedMessage(true));
                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.True);
            }
        }
Exemple #2
0
        private CogProject SetupProjectWithThreeMeanings(WordListsViewModelTestEnvironment env)
        {
            var project = new CogProject(env.SpanFactory)
            {
                Meanings = { new Meaning("gloss1", "cat1"), new Meaning("gloss2", "cat2"), new Meaning("gloss3", "cat3") }
            };

            env.OpenProject(project);
            return(project);
        }
Exemple #3
0
        public void Varieties_OpenProject_VarietiesPopulated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithThreeVarieties(env);

                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] { "variety1", "variety2", "variety3" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
Exemple #4
0
        public void Meanings_OpenProject_MeaningsPopulated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithThreeMeanings(env);

                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] { "gloss1", "gloss2", "gloss3" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
Exemple #5
0
        private CogProject SetupProjectWithThreeVarieties(WordListsViewModelTestEnvironment env)
        {
            var project = new CogProject(env.SpanFactory)
            {
                Varieties = { new Variety("variety1"), new Variety("variety2"), new Variety("variety3") }
            };

            env.OpenProject(project);
            return(project);
        }
Exemple #6
0
        public void Meanings_Remove_MeaningRemoved()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProjectWithThreeMeanings(env);

                project.Meanings.RemoveAt(0);
                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] { "gloss2", "gloss3" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
Exemple #7
0
        public void Varieties_Remove_VarietyRemoved()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProjectWithThreeVarieties(env);

                project.Varieties.RemoveAt(0);
                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] { "variety2", "variety3" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
        private CogProject SetupProject(WordListsViewModelTestEnvironment env)
        {
            var project = new CogProject(env.SpanFactory)
            {
                Meanings  = { new Meaning("gloss1", "cat1") },
                Varieties = { new Variety("variety1") }
            };

            env.OpenProject(project);
            return(project);
        }
Exemple #9
0
        public void Varieties_Clear_AllVarietiesRemoved()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProjectWithThreeVarieties(env);

                project.Varieties.Clear();
                Assert.That(env.WordListsViewModel.Varieties.Count, Is.EqualTo(0));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.True);
            }
        }
        public void StrRep_SetStrRepWithSpaces_WordsUpdated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProject(env);
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];

                varietyMeaning.StrRep = " hɛ.lp,gu.gəl ,gu.fi ";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] {"hɛ.lp", "gu.gəl", "gu.fi"}));
                Assert.That(varietyMeaning.StrRep, Is.EqualTo("hɛ.lp,gu.gəl,gu.fi"));
            }
        }
        public void FindCommand_DialogOpen_NotOpenedAgain()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithWords(env);
                env.OpenFindDialog();

                env.DialogService.ClearReceivedCalls();
                env.WordListsViewModel.FindCommand.Execute(null);
                env.DialogService.DidNotReceive().ShowModelessDialog(env.WordListsViewModel, Arg.Any<FindViewModel>(), Arg.Any<Action>());
            }
        }
Exemple #12
0
        public void FindCommand_DialogOpen_NotOpenedAgain()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithWords(env);
                env.OpenFindDialog();

                env.DialogService.ClearReceivedCalls();
                env.WordListsViewModel.FindCommand.Execute(null);
                env.DialogService.DidNotReceive().ShowModelessDialog(env.WordListsViewModel, Arg.Any <FindViewModel>(), Arg.Any <Action>());
            }
        }
        public void StrRep_SetStrRepWithSpaces_WordsUpdated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProject(env);
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];

                varietyMeaning.StrRep = " hɛ.lp,gu.gəl ,gu.fi ";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] { "hɛ.lp", "gu.gəl", "gu.fi" }));
                Assert.That(varietyMeaning.StrRep, Is.EqualTo("hɛ.lp,gu.gəl,gu.fi"));
            }
        }
        public void StrRep_SetStrRepNull_WordsEmpty()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProject(env);
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];

                project.Varieties[0].Words.Add(new Word("hɛ.loʊ", project.Meanings[0]));

                varietyMeaning.StrRep = null;
                Assert.That(varietyMeaning.Words, Is.Empty);
            }
        }
        public void StrRep_SetStrRepNull_WordsEmpty()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = env.OpenProject(new[] {new Meaning("gloss1", "cat1")}, new[] {new Variety("variety1")});
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordLists.Varieties[0].Meanings[0];

                project.Varieties[0].Words.Add(new Word("hɛ.loʊ", project.Meanings[0]));

                varietyMeaning.StrRep = null;
                Assert.That(varietyMeaning.Words, Is.Empty);
            }
        }
Exemple #16
0
        private void SetupProjectWithWords(WordListsViewModelTestEnvironment env)
        {
            var project = new CogProject(env.SpanFactory)
            {
                Meanings  = { new Meaning("gloss1", "cat1"), new Meaning("gloss2", "cat2"), new Meaning("gloss3", "cat3") },
                Varieties = { new Variety("variety1"), new Variety("variety2") }
            };

            project.Varieties[0].Words.AddRange(new[] { new Word("hello", project.Meanings[0]), new Word("good", project.Meanings[1]), new Word("bad", project.Meanings[2]) });
            project.Varieties[1].Words.AddRange(new[] { new Word("help", project.Meanings[0]), new Word("google", project.Meanings[1]), new Word("batter", project.Meanings[2]) });

            env.OpenProject(project);
        }
        public void StrRep_SetStrRepNull_WordsEmpty()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProject(env);
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];

                project.Varieties[0].Words.Add(new Word("hɛ.loʊ", project.Meanings[0]));

                varietyMeaning.StrRep = null;
                Assert.That(varietyMeaning.Words, Is.Empty);
            }
        }
Exemple #18
0
        public void FindCommand_GlossNothingSelectedNoMatches_NoWordSelected()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithWords(env);
                env.OpenFindDialog();

                env.FindViewModel.Field  = FindField.Gloss;
                env.FindViewModel.String = "gloss4";
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.Null);
            }
        }
Exemple #19
0
        public void Meanings_Add_MeaningAdded()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = new CogProject(env.SpanFactory)
                {
                    Meanings = { new Meaning("gloss2", "cat2"), new Meaning("gloss3", "cat3") }
                };
                env.OpenProject(project);

                project.Meanings.Add(new Meaning("gloss1", "cat1"));
                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] { "gloss2", "gloss3", "gloss1" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
Exemple #20
0
        public void FindCommand_GlossNothingSelectedMatches_CorrectWordsSelected()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithWords(env);
                env.OpenFindDialog();

                env.FindViewModel.Field  = FindField.Gloss;
                env.FindViewModel.String = "gloss2";
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.EqualTo(env.WordListsViewModel.Varieties[0].Meanings[1]));
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.EqualTo(env.WordListsViewModel.Varieties[0].Meanings[1]));
            }
        }
Exemple #21
0
        public void Varieties_Add_VarietyAdded()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = new CogProject(env.SpanFactory)
                {
                    Varieties = { new Variety("variety2"), new Variety("variety3") }
                };
                env.OpenProject(project);

                project.Varieties.Add(new Variety("variety1"));
                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] { "variety2", "variety3", "variety1" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
Exemple #22
0
        public void TaskAreas_AddVarietyCommandExecuted_VarietyAdded()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProjectWithThreeVarieties(env);

                var commonTasks = (TaskAreaItemsViewModel)env.WordListsViewModel.TaskAreas[0];

                // add a new variety
                var addVariety = (TaskAreaCommandViewModel)commonTasks.Items[0];
                env.DialogService.ShowModalDialog(env.WordListsViewModel, Arg.Do <EditVarietyViewModel>(vm => vm.Name = "variety4")).Returns(true);
                addVariety.Command.Execute(null);

                Assert.That(project.Varieties.Select(v => v.Name), Is.EqualTo(new[] { "variety1", "variety2", "variety3", "variety4" }));
            }
        }
        public void Words_AddWord_StrRepAndWordsUpdated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProject(env);
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];

                project.Varieties[0].Words.Add(new Word("hɛ.loʊ", project.Meanings[0]));
                Assert.That(varietyMeaning.StrRep, Is.EqualTo("hɛ.loʊ"));
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] { "hɛ.loʊ" }));

                project.Varieties[0].Words.Add(new Word("gu.gəl", project.Meanings[0]));

                Assert.That(varietyMeaning.StrRep, Is.EqualTo("hɛ.loʊ,gu.gəl"));
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] { "hɛ.loʊ", "gu.gəl" }));
            }
        }
        public void FindCommand_FormLastWordSelectedMatches_CorrectWordsSelected()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithWords(env);
                env.OpenFindDialog();

                env.FindViewModel.Field = FindField.Form;
                env.WordListsViewModel.SelectedVarietyMeaning = env.WordListsViewModel.Varieties[1].Meanings[2];
                env.FindViewModel.String = "ba";
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.EqualTo(env.WordListsViewModel.Varieties[0].Meanings[2]));
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.EqualTo(env.WordListsViewModel.Varieties[1].Meanings[2]));
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.EqualTo(env.WordListsViewModel.Varieties[1].Meanings[2]));
            }
        }
Exemple #25
0
        public void Varieties_ReopenProject_VarietiesPopulated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithThreeVarieties(env);

                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] { "variety1", "variety2", "variety3" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);

                var project = new CogProject(env.SpanFactory)
                {
                    Varieties = { new Variety("variety1") }
                };
                env.OpenProject(project);

                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] { "variety1" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
Exemple #26
0
        public void Meanings_ReopenProject_MeaningsPopulated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithThreeMeanings(env);

                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] { "gloss1", "gloss2", "gloss3" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);

                CogProject project = new CogProject(env.SpanFactory)
                {
                    Meanings = { new Meaning("gloss1", "cat1") }
                };
                env.OpenProject(project);

                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] { "gloss1" }));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
Exemple #27
0
        public void FindCommand_FormLastWordSelectedChangeSelectedWord_CorrectWordsSelected()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithWords(env);
                env.OpenFindDialog();

                env.FindViewModel.Field = FindField.Form;
                env.WordListsViewModel.SelectedVarietyMeaning = env.WordListsViewModel.Varieties[1].Meanings[2];
                env.FindViewModel.String = "ba";
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.EqualTo(env.WordListsViewModel.Varieties[0].Meanings[2]));
                env.WordListsViewModel.SelectedVarietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.EqualTo(env.WordListsViewModel.Varieties[0].Meanings[2]));
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.EqualTo(env.WordListsViewModel.Varieties[1].Meanings[2]));
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.EqualTo(env.WordListsViewModel.Varieties[1].Meanings[2]));
            }
        }
        public void StrRep_SetStrRep_VarietyIsValidUpdated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                var segmenter = new Segmenter(env.SpanFactory)
                {
                    Consonants = { "b", "t" },
                    Vowels     = { "a" }
                };
                env.AnalysisService.Segment(Arg.Do <Variety>(variety => segmenter.Segment(variety.Words.First())));
                SetupProject(env);
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];

                varietyMeaning.StrRep = "cat";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] { "cat" }));
                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.False);

                varietyMeaning.StrRep = "bat";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] { "bat" }));
                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.True);
            }
        }
        public void StrRep_SetStrRep_VarietyIsValidUpdated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                var segmenter = new Segmenter(env.SpanFactory)
                {
                    Consonants = {"b", "t"},
                    Vowels = {"a"}
                };
                env.AnalysisService.Segment(Arg.Do<Variety>(variety => segmenter.Segment(variety.Words.First())));
                SetupProject(env);
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];

                varietyMeaning.StrRep = "cat";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] {"cat"}));
                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.False);

                varietyMeaning.StrRep = "bat";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] {"bat"}));
                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.True);
            }
        }
        private void SetupProjectWithWords(WordListsViewModelTestEnvironment env)
        {
            var project = new CogProject(env.SpanFactory)
                {
                    Meanings = {new Meaning("gloss1", "cat1"), new Meaning("gloss2", "cat2"), new Meaning("gloss3", "cat3")},
                    Varieties = {new Variety("variety1"), new Variety("variety2")}
                };
            project.Varieties[0].Words.AddRange(new[] {new Word("hello", project.Meanings[0]), new Word("good", project.Meanings[1]), new Word("bad", project.Meanings[2])});
            project.Varieties[1].Words.AddRange(new[] {new Word("help", project.Meanings[0]), new Word("google", project.Meanings[1]), new Word("batter", project.Meanings[2])});

            env.OpenProject(project);
        }
 private CogProject SetupProjectWithThreeVarieties(WordListsViewModelTestEnvironment env)
 {
     var project = new CogProject(env.SpanFactory)
     {
         Varieties = {new Variety("variety1"), new Variety("variety2"), new Variety("variety3")}
     };
     env.OpenProject(project);
     return project;
 }
 private CogProject SetupProjectWithThreeMeanings(WordListsViewModelTestEnvironment env)
 {
     var project = new CogProject(env.SpanFactory)
     {
         Meanings = {new Meaning("gloss1", "cat1"), new Meaning("gloss2", "cat2"), new Meaning("gloss3", "cat3")}
     };
     env.OpenProject(project);
     return project;
 }
        public void Varieties_ReopenProject_VarietiesPopulated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithThreeVarieties(env);

                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] {"variety1", "variety2", "variety3"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);

                var project = new CogProject(env.SpanFactory) {Varieties = {new Variety("variety1")}};
                env.OpenProject(project);

                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] {"variety1"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
 private CogProject SetupProject(WordListsViewModelTestEnvironment env)
 {
     var project = new CogProject(env.SpanFactory)
     {
         Meanings = {new Meaning("gloss1", "cat1")},
         Varieties = {new Variety("variety1")}
     };
     env.OpenProject(project);
     return project;
 }
        public void StrRep_SetStrRep_WordsUpdated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                env.OpenProject(new[] {new Meaning("gloss1", "cat1")}, new[] {new Variety("variety1")});
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordLists.Varieties[0].Meanings[0];

                varietyMeaning.StrRep = "hɛ.lp,gu.gəl";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] {"hɛ.lp", "gu.gəl"}));

                varietyMeaning.StrRep = "hɛ.lp";
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] {"hɛ.lp"}));
            }
        }
        public void Varieties_Clear_AllVarietiesRemoved()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProjectWithThreeVarieties(env);

                project.Varieties.Clear();
                Assert.That(env.WordListsViewModel.Varieties.Count, Is.EqualTo(0));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.True);
            }
        }
        public void Varieties_Add_VarietyAdded()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = new CogProject(env.SpanFactory)
                {
                    Varieties = {new Variety("variety2"), new Variety("variety3")}
                };
                env.OpenProject(project);

                project.Varieties.Add(new Variety("variety1"));
                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] {"variety2", "variety3", "variety1"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
        public void Meanings_ReopenProject_MeaningsPopulated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithThreeMeanings(env);

                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] {"gloss1", "gloss2", "gloss3"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);

                CogProject project = new CogProject(env.SpanFactory)
                {
                    Meanings = {new Meaning("gloss1", "cat1")}
                };
                env.OpenProject(project);

                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] {"gloss1"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
        public void Meanings_Remove_MeaningRemoved()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProjectWithThreeMeanings(env);

                project.Meanings.RemoveAt(0);
                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] {"gloss2", "gloss3"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
        public void Meanings_OpenProject_MeaningsPopulated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithThreeMeanings(env);

                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] {"gloss1", "gloss2", "gloss3"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
        public void FindCommand_GlossNothingSelectedNoMatches_NoWordSelected()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithWords(env);
                env.OpenFindDialog();

                env.FindViewModel.Field = FindField.Gloss;
                env.FindViewModel.String = "gloss4";
                env.FindViewModel.FindNextCommand.Execute(null);
                Assert.That(env.WordListsViewModel.SelectedVarietyMeaning, Is.Null);
            }
        }
        public void Words_AddWord_StrRepAndWordsUpdated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProject(env);
                WordListsVarietyMeaningViewModel varietyMeaning = env.WordListsViewModel.Varieties[0].Meanings[0];

                project.Varieties[0].Words.Add(new Word("hɛ.loʊ", project.Meanings[0]));
                Assert.That(varietyMeaning.StrRep, Is.EqualTo("hɛ.loʊ"));
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] {"hɛ.loʊ"}));

                project.Varieties[0].Words.Add(new Word("gu.gəl", project.Meanings[0]));

                Assert.That(varietyMeaning.StrRep, Is.EqualTo("hɛ.loʊ,gu.gəl"));
                Assert.That(varietyMeaning.Words.Select(w => w.StrRep), Is.EqualTo(new[] {"hɛ.loʊ", "gu.gəl"}));
            }
        }
        public void Varieties_DomainModelChangedMessage_CheckForErrors()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                var project = new CogProject(env.SpanFactory);
                env.OpenProject(project);

                project.Meanings.Add(new Meaning("gloss1", "cat1"));
                var bat = new Word("bat", project.Meanings[0]);
                project.Varieties.Add(new Variety("variety1") {Words = {bat}});

                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.False);

                var segmenter = new Segmenter(env.SpanFactory)
                {
                    Consonants = {"b", "t"},
                    Vowels = {"a"}
                };
                segmenter.Segment(bat);

                Messenger.Default.Send(new DomainModelChangedMessage(true));
                Assert.That(env.WordListsViewModel.Varieties[0].IsValid, Is.True);
            }
        }
        public void Varieties_OpenProject_VarietiesPopulated()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                SetupProjectWithThreeVarieties(env);

                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] {"variety1", "variety2", "variety3"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
        public void Varieties_Remove_VarietyRemoved()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProjectWithThreeVarieties(env);

                project.Varieties.RemoveAt(0);
                Assert.That(env.WordListsViewModel.Varieties.Select(v => v.Name), Is.EqualTo(new[] {"variety2", "variety3"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }
        public void TaskAreas_AddVarietyCommandExecuted_VarietyAdded()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = SetupProjectWithThreeVarieties(env);

                var commonTasks = (TaskAreaItemsViewModel) env.WordListsViewModel.TaskAreas[0];

                // add a new variety
                var addVariety = (TaskAreaCommandViewModel) commonTasks.Items[0];
                env.DialogService.ShowModalDialog(env.WordListsViewModel, Arg.Do<EditVarietyViewModel>(vm => vm.Name = "variety4")).Returns(true);
                addVariety.Command.Execute(null);

                Assert.That(project.Varieties.Select(v => v.Name), Is.EqualTo(new[] {"variety1", "variety2", "variety3", "variety4"}));
            }
        }
        public void Meanings_Add_MeaningAdded()
        {
            using (var env = new WordListsViewModelTestEnvironment())
            {
                CogProject project = new CogProject(env.SpanFactory)
                {
                    Meanings = {new Meaning("gloss2", "cat2"), new Meaning("gloss3", "cat3")}
                };
                env.OpenProject(project);

                project.Meanings.Add(new Meaning("gloss1", "cat1"));
                Assert.That(env.WordListsViewModel.Meanings.Select(s => s.Gloss), Is.EqualTo(new[] {"gloss2", "gloss3", "gloss1"}));
                Assert.That(env.WordListsViewModel.IsEmpty, Is.False);
            }
        }