public void TestSetNull2() { HashTags <string> a = new HashTags <string>(); a.SetTag("SomethingElseFirst", "hello"); a.SetTag((string)null, "hi"); }
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); }
void AddFour(HashTags<string> a) { a.SetTag("Food", "Pizza"); a.SetTag("Drink", "Mountain Dew"); a.SetTag("Genitals", "Male"); a.SetTag("Disposition", "Insane"); }
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)); }
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))); }
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); }
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); }
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); }
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); }
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()); }
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")); }
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")); }
public void TestSetNull1() { HashTags<string> a = new HashTags<string>(); a.SetTag((Symbol)null, "hello"); }
public bool Contains(string s) { s = s.ToLower(); return(Content.ToLower().Contains(s) || HashTags.ToLower().Contains(s)); }
public void TestSetNull2() { HashTags<string> a = new HashTags<string>(); a.SetTag("SomethingElseFirst", "hello"); a.SetTag((string)null, "hi"); }
public void TestFromEmpty() { HashTags <string> a = new HashTags <string>(); TestTheBasics(a, true); }
public void TestFromEmpty() { HashTags<string> a = new HashTags<string>(); TestTheBasics(a, true); }
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()); }
private string MostTrending() { hashTag = new HashTags(); return(hashTag.MostTrending()); }
public void TestSetNull1() { HashTags <string> a = new HashTags <string>(); a.SetTag((Symbol)null, "hello"); }