public void GetMessages_SearchContainsAuthor_FindsMatches()
 {
     using (var folder = new TemporaryFolder("NotesModelTests"))
     {
         string contents = "<annotation><message author='john'></message></annotation>";
         using (CreateNotesFile(folder, contents))
         {
             var m = new NotesInProjectViewModel(TheUser, AnnotationRepository.CreateRepositoriesFromFolder(folder.Path, _progress), new MessageSelectedEvent(), new ChorusNotesDisplaySettings(), new ConsoleProgress());
             m.SearchTextChanged("john");
             Assert.AreEqual(1, m.GetMessages().Count());
         }
     }
 }
        public void GetMessages_SearchContainsWordInMessageInUpperCase_FindsMatches()
        {
            using (var folder = new TemporaryFolder("NotesModelTests"))
            {
                string contents = @"<annotation class='question'><message author='john'></message></annotation>
                <annotation class='note'><message author='bob'>my mESsage contents</message></annotation>";
                using (CreateNotesFile(folder, contents))
                {
                    var repos = AnnotationRepository.CreateRepositoriesFromFolder(folder.Path, _progress);
                    var m = new NotesInProjectViewModel(TheUser, repos, new MessageSelectedEvent(), new ChorusNotesDisplaySettings(), new ConsoleProgress());
                    Assert.AreEqual(2, m.GetMessages().Count(), "should get 2 annotations when search box is empty");
                    m.SearchTextChanged("MesSAGE");//es is lower case
                    Assert.AreEqual(1, m.GetMessages().Count());
                    Assert.AreEqual("bob", m.GetMessages().First().Message.Author);

                }
            }
        }
 public void GetMessages_ReturnsMostRecentMessagePassingFilterInAnnotation()
 {
     using (var folder = new TemporaryFolder("NotesModelTests"))
     {
         string contents = @"<annotation class='question'>
             <message author='fred' date='2013-01-22T20:37:30Z'/>
             <message author='john' date='2013-01-22T20:37:36Z'/>
             <message author='john' date='2013-01-22T20:37:35Z'/>
             <message author='bill' date='2013-01-22T20:37:39Z'/>
         </annotation>
         <annotation class='note'><message author='bob' date='2013-01-22T20:37:20Z'></message></annotation>";
         using (CreateNotesFile(folder, contents))
         {
             var repos = AnnotationRepository.CreateRepositoriesFromFolder(folder.Path, _progress);
             var m = new NotesInProjectViewModel(TheUser, repos, new MessageSelectedEvent(), new ChorusNotesDisplaySettings(),
                 new ConsoleProgress());
             Assert.AreEqual(2, m.GetMessages().Count(), "Should get one from each annotation by default");
             Assert.That(m.GetMessages().First().Message.Author, Is.EqualTo("bill"), "bill's is the newest message");
             Assert.That(m.GetMessages().Last().Message.Author, Is.EqualTo("bob"), "bob's is the oldest message");
             m.SearchTextChanged("john");
             Assert.AreEqual(1, m.GetMessages().Count(), "Should only get a message from the annotation where one passes filter");
             Assert.That(m.GetMessages().First().Message.Author, Is.EqualTo("john"), "Should get one of John's messages (that pass filter)");
             Assert.That(m.GetMessages().First().Message.Date.Second, Is.EqualTo(36), "Should the newest message passing the filter");
         }
     }
 }