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);
            }
        }
Exemplo n.º 2
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);
            }
        }