Exemplo n.º 1
0
        private bool CompareTweets(SearchResult other)
        {
            bool result = false;
            if (User != null && other.User != null)
            {
                if (Text == other.Text &&
                   User.Name == other.User.Name)
                {
                    result = true;
                }
            }

            return result;
        }
        private SearchResult ToSearchResult(XElement entry)
        {
            var text = (string) entry.Element(ns + "title");
            var dateCreated = ParseDateTime((string) entry.Element(ns + "updated"));
            var source = (string) entry.Element(twitter + "source");

            var user = new User();            
            ExtractImage(entry, user);
            ExtractAuthor(entry, user);

            var result = new SearchResult
            {
                AssociatedSearchItem = _item,
                Text = text,
                DateCreated = dateCreated,
                Source = source,
                User = user
            };

            result.UpdateRelativeTime();
            return result;
        }
Exemplo n.º 3
0
        public void it_keeps_most_recent_result_first()
        {
            var result1 = new SearchResult()
            {
                AssociatedSearchItem = new SearchItem(),
                DateCreated = new DateTime(2007,1,1),
                Text = "old",
                User = new User
                {
                    Name="foo"
                }
            };

            _model.SearchResults.AddResults(Enumerable.Repeat(result1,1).ToList());

            var result2 = new SearchResult()
            {
                AssociatedSearchItem = new SearchItem(),
                DateCreated = new DateTime(2010,1,1),
                Text = "new",
                User = new User
                {
                    Name="foo"
                }
            };

            _model.SearchResults.AddResults(Enumerable.Repeat(result2,1).ToList());

            Assert.That(_model.SearchResults.First().Text == "new");
        }
Exemplo n.º 4
0
 public bool Equals(SearchResult other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return CompareTweets(other);
 }