示例#1
0
        public void TestSetNull2()
        {
            HashTags <string> a = new HashTags <string>();

            a.SetTag("SomethingElseFirst", "hello");
            a.SetTag((string)null, "hi");
        }
示例#2
0
 override public string ToString()
 {
     return("Twitter Post: " + Text + System.Environment.NewLine +
            "Amount of Likes: " + Likes + System.Environment.NewLine +
            "What Hashtags used: " + HashTags.ToString() + System.Environment.NewLine +
            "TThe URL of post: " + URL);
 }
示例#3
0
		void AddFour(HashTags<string> a)
		{
			a.SetTag("Food", "Pizza");
			a.SetTag("Drink", "Mountain Dew");
			a.SetTag("Genitals", "Male");
			a.SetTag("Disposition", "Insane");
		}
示例#4
0
 void AddFour(HashTags <string> a)
 {
     a.SetTag("Food", "Pizza");
     a.SetTag("Drink", "Mountain Dew");
     a.SetTag("Genitals", "Male");
     a.SetTag("Disposition", "Insane");
 }
        public bool DeleteTweet(int uId, int tweetId)
        {
            mapper           = new PostTagMapOperation();
            operationOnTweet = new TweetOperation();
            operationOnTag   = new HashTags();

            tagId = mapper.RetrieveTagId(tweetId);
            mapper.Remove(tweetId);
            operationOnTag.RemoveHashtag(tagId);
            return(operationOnTweet.RemoveTweet(uId, tweetId));
        }
示例#6
0
        public Article(string title, string content)
        {
            Title   = title;
            Content = content;

            foreach (var hashTag in HashTag.Parse(content))
            {
                _hashTags.Add(hashTag);
            }

            AddDomainEvent(new ArticleCreatedEvent(Title, HashTags.Select(ht => ht.Id)));
        }
示例#7
0
        public IEnumerable <TwitterEntity> Coalesce()
        {
            var entities = new List <TwitterEntity>(Mentions.Count() + HashTags.Count() + Urls.Count() + Media.Count());

            entities.AddRange(Mentions.Cast <TwitterEntity>());
            entities.AddRange(HashTags.Cast <TwitterEntity>());
            entities.AddRange(Urls.Cast <TwitterEntity>());
            entities.AddRange(Media.Cast <TwitterEntity>());
            entities.Sort();

            return(entities);
        }
示例#8
0
        public void TestFromFour()
        {
            HashTags <string> a = new HashTags <string>();

            AddFour(a);
            TestTheBasics(a, false);

            // There should be four left
            IEnumerator <KeyValuePair <Symbol, string> > e = a.TagEnumerator();

            for (int i = 0; i < 4; i++)
            {
                Assert.IsTrue(e.MoveNext());
            }
            Assert.IsFalse(e.MoveNext());
        }
        public bool AddTweet(TweetDto newTweet)
        {
            operationOnTweet = new TweetOperation();
            operationOnTag   = new HashTags();
            int tweetId;

            newTweet.Body = newTweet.Body.Trim();
            if (string.IsNullOrEmpty(newTweet.Body))
            {
                return(false);
            }
            tweetId = operationOnTweet.AddTweet(newTweet);

            tagList = SplitTweet(newTweet.Body);
            tagId   = operationOnTag.AddHashTag(tagList);
            TweetTagMap(tweetId, tagId);
            return(true);
        }
示例#10
0
        public IEnumerable <TwitterEntity> Coalesce()
        {
#if !WINDOWS_PHONE
            var entities = new List <TwitterEntity>(Mentions.Count() + HashTags.Count() + Urls.Count());
            entities.AddRange((IEnumerable <TwitterEntity>)Mentions);
            entities.AddRange((IEnumerable <TwitterEntity>)HashTags);
            entities.AddRange((IEnumerable <TwitterEntity>)Urls);
            entities.Sort();
#else
            var entities = new List <TwitterEntity>(Mentions.Count() + HashTags.Count() + Urls.Count());
            entities.AddRange(Mentions.Cast <TwitterEntity>());
            entities.AddRange(HashTags.Cast <TwitterEntity>());
            entities.AddRange(Urls.Cast <TwitterEntity>());
            entities.Sort();
#endif

            return(entities);
        }
示例#11
0
 public bool UpdateTweet(TweetDto newTweet)
 {
     operationOnTweet = new TweetOperation();
     operationOnTag   = new HashTags();
     mapper           = new PostTagMapOperation();
     newTweet.Body    = newTweet.Body.Trim();
     tagList          = SplitTweet(newTweet.Body);
     if (string.IsNullOrEmpty(newTweet.Body))
     {
         return(false);
     }
     tagId = mapper.RetrieveTagId(newTweet.id);
     mapper.Remove(newTweet.id);
     operationOnTag.RemoveHashtag(tagId);
     tagId = operationOnTag.AddHashTag(tagList);
     operationOnTweet.EditTweet(newTweet);
     TweetTagMap(newTweet.id, tagId);
     return(true);
 }
示例#12
0
        public string GetShareUrl()
        {
            //画像付きツイートの場合はゲームURLと画像URLを持つことになる。
            //TwitterCardとして表示させるために、画像URLをメインのURLとして利用する。
            var url = HasImageUrl ? ImageUrl : GameUrl;
            //画像ツイートの場合はゲームURLをテキストに含む
            var text = HasImageUrl ? (Text + " " + GameUrl) : Text;

            var sb = new StringBuilder();

            sb.Append(ShareUrl);
            sb.Append("&url=" + WWW.EscapeURL(url));
            sb.Append("&text=" + WWW.EscapeURL(text));
            if (HashTags.Any())
            {
                var hashTagText = string.Join(",", HashTags.ToArray());
                sb.Append("&hashtags=" + WWW.EscapeURL(hashTagText));
            }

            return(sb.ToString());
        }
示例#13
0
        private void TestTheBasics(HashTags <string> a, bool startsEmpty)
        {
            // This test is run twice, once on a set that starts empty (to
            // test the one-element code paths) and again on a set that has
            // unrelated stuff in it already.
            IEnumerator <KeyValuePair <Symbol, string> > e;

            // Sanity checks
            Assert.IsNull(a.GetTag((string)null));
            Assert.IsFalse(a.RemoveTag("Nonexistant"));
            Assert.IsFalse(a.HasTag("Nonexistant"));

            a.SetTag("One", "Two");
            Assert.AreEqual(a.GetTag("One"), "Two");

            // Test the enumerator
            e = a.TagEnumerator();
            Assert.IsTrue(e.MoveNext());
            if (startsEmpty)
            {
                Assert.AreEqual(GSymbol.Get("One"), e.Current.Key);
                Assert.AreEqual("Two", e.Current.Value);
                Assert.IsFalse(e.MoveNext());
            }

            // Remove what we added
            Assert.IsNull(a.GetTag((string)null));
            Assert.IsFalse(a.RemoveTag(""));
            Assert.IsTrue(a.RemoveTag("One"));
            Assert.IsNull(a.GetTag("One"));

            if (startsEmpty)
            {
                e = a.TagEnumerator();
                Assert.IsFalse(e.MoveNext());
            }

            // Do almost the same thing again: add an attr, then remove it
            a.SetTag("One", "Two");
            Assert.AreEqual("Two", a.GetTag("One"));
            Assert.IsTrue(a.HasTag("One"));
            Assert.IsTrue(a.RemoveTag("One"));
            Assert.IsNull(a.GetTag("One"));

            // A different attribute
            a.SetTag("Two", "Three");
            Assert.AreEqual("Three", a.GetTag("Two"));
            a.SetTag("Two", "Four");
            a.SetTag("Two", "Two");
            Assert.AreEqual("Two", a.GetTag("Two"));

            // Another attribute should not disturb the first
            a.SetTag("Three", "Four");
            Assert.AreEqual("Two", a.GetTag("Two"));
            Assert.IsFalse(a.HasTag("One"));
            Assert.IsTrue(a.HasTag("Two"));
            Assert.IsTrue(a.HasTag("Three"));

            // Test the enumerator
            e = a.TagEnumerator();
            Assert.IsTrue(e.MoveNext());
            Assert.IsTrue(e.MoveNext());
            if (startsEmpty)
            {
                Assert.IsFalse(e.MoveNext());
            }

            // Clean up by removing all that we added
            Assert.IsTrue(a.RemoveTag("Two"));
            Assert.IsTrue(a.RemoveTag("Three"));
        }
示例#14
0
		private void TestTheBasics(HashTags<string> a, bool startsEmpty)
		{
			// This test is run twice, once on a set that starts empty (to
			// test the one-element code paths) and again on a set that has
			// unrelated stuff in it already.
			IEnumerator<KeyValuePair<Symbol, string>> e;

			// Sanity checks
			Assert.IsNull(a.GetTag((string)null));
			Assert.IsFalse(a.RemoveTag("Nonexistant"));
			Assert.IsFalse(a.HasTag("Nonexistant"));

			a.SetTag("One", "Two");
			Assert.AreEqual(a.GetTag("One"), "Two");

			// Test the enumerator
			e = a.TagEnumerator();
			Assert.IsTrue(e.MoveNext());
			if (startsEmpty)
			{
				Assert.AreEqual(GSymbol.Get("One"), e.Current.Key);
				Assert.AreEqual("Two", e.Current.Value);
				Assert.IsFalse(e.MoveNext());
			}

			// Remove what we added
			Assert.IsNull(a.GetTag((string)null));
			Assert.IsFalse(a.RemoveTag(""));
			Assert.IsTrue(a.RemoveTag("One"));
			Assert.IsNull(a.GetTag("One"));

			if (startsEmpty)
			{
				e = a.TagEnumerator();
				Assert.IsFalse(e.MoveNext());
			}

			// Do almost the same thing again: add an attr, then remove it
			a.SetTag("One", "Two");
			Assert.AreEqual("Two", a.GetTag("One"));
			Assert.IsTrue(a.HasTag("One"));
			Assert.IsTrue(a.RemoveTag("One"));
			Assert.IsNull(a.GetTag("One"));

			// A different attribute
			a.SetTag("Two", "Three");
			Assert.AreEqual("Three", a.GetTag("Two"));
			a.SetTag("Two", "Four");
			a.SetTag("Two", "Two");
			Assert.AreEqual("Two", a.GetTag("Two"));

			// Another attribute should not disturb the first
			a.SetTag("Three", "Four");
			Assert.AreEqual("Two", a.GetTag("Two"));
			Assert.IsFalse(a.HasTag("One"));
			Assert.IsTrue(a.HasTag("Two"));
			Assert.IsTrue(a.HasTag("Three"));

			// Test the enumerator
			e = a.TagEnumerator();
			Assert.IsTrue(e.MoveNext());
			Assert.IsTrue(e.MoveNext());
			if (startsEmpty)
				Assert.IsFalse(e.MoveNext());

			// Clean up by removing all that we added
			Assert.IsTrue(a.RemoveTag("Two"));
			Assert.IsTrue(a.RemoveTag("Three"));
		}
示例#15
0
		public void TestSetNull1()
		{
			HashTags<string> a = new HashTags<string>();
			a.SetTag((Symbol)null, "hello");
		}
示例#16
0
 public bool Contains(string s)
 {
     s = s.ToLower();
     return(Content.ToLower().Contains(s) || HashTags.ToLower().Contains(s));
 }
示例#17
0
		public void TestSetNull2()
		{
			HashTags<string> a = new HashTags<string>();
			a.SetTag("SomethingElseFirst", "hello");
			a.SetTag((string)null, "hi");
		}
示例#18
0
        public void TestFromEmpty()
        {
            HashTags <string> a = new HashTags <string>();

            TestTheBasics(a, true);
        }
示例#19
0
		public void TestFromEmpty()
		{
			HashTags<string> a = new HashTags<string>();
			TestTheBasics(a, true);
		}
示例#20
0
		public void TestFromFour()
		{
			HashTags<string> a = new HashTags<string>();
			AddFour(a);
			TestTheBasics(a, false);

			// There should be four left
			IEnumerator<KeyValuePair<Symbol, string>> e = a.TagEnumerator();
			for (int i = 0; i < 4; i++)
				Assert.IsTrue(e.MoveNext());
			Assert.IsFalse(e.MoveNext());
		}
示例#21
0
 private string MostTrending()
 {
     hashTag = new HashTags();
     return(hashTag.MostTrending());
 }
示例#22
0
        public void TestSetNull1()
        {
            HashTags <string> a = new HashTags <string>();

            a.SetTag((Symbol)null, "hello");
        }