Example #1
0
        public void Employees()
        {
            var source = new TwitterSource();
            var data   = source.Employees(5);

            Assert.IsNotNull(data);
            Assert.IsTrue(5 * 3 >= data.Count());
            foreach (var item in data)
            {
                if (item.ScreenName.ToLowerInvariant() == TwitterSource.JefKing.ToLowerInvariant() ||
                    item.ScreenName.ToLowerInvariant() == TwitterSource.GeorgeDanes.ToLowerInvariant() ||
                    item.ScreenName.ToLowerInvariant() == TwitterSource.JaimeBueza.ToLowerInvariant())
                {
                    continue;
                }
                else
                {
                    Assert.Fail(string.Format("Unknown User Name: {0}", item.User.ScreenName));
                }

                if (item.Text.Contains('@') || item.Text.Contains('#'))
                {
                    if (!RegexStatement.Url.IsMatch(item.Text))
                    {
                        Assert.Fail(string.Format("Item Contains @ | # yet doesn't have link to twitter: '{0}'", item.Text));
                    }
                }
            }
        }
Example #2
0
        public void Tweets()
        {
            var source = new TwitterSource();
            var data   = source.ByUser("weareabc", 5).ToList();

            Assert.IsNotNull(data);
            Assert.AreEqual <int>(5, data.Count());
        }
Example #3
0
        public void RenderHtmlLink()
        {
            var status = new Status()
            {
                Text = "hey link land: http://t.com/happy click it",
            };

            var source = new TwitterSource();

            var html = source.RenderHtml(status);

            Assert.AreEqual <string>("hey link land: <a href=\"http://t.com/happy\" target=\"_blank\">http://t.com/happy</a> click it", html);
        }
Example #4
0
        public void RenderHtml()
        {
            var status = new Status()
            {
                Text = "Hey @someone check #this out! http://happy.com/land",
            };

            var source = new TwitterSource();

            var html = source.RenderHtml(status);

            Assert.AreEqual <string>("Hey @<a href=\"http://www.twitter.com/#!/someone\" target=\"_blank\">someone</a> check <a href=\"http://www.twitter.com/#!/search?q=this\" target=\"_blank\">#this</a> out! <a href=\"http://happy.com/land\" target=\"_blank\">http://happy.com/land</a>", html);
        }
Example #5
0
        public void RenderHtmlKeyword()
        {
            var status = new Status()
            {
                Text = "This is so cool #Dude check yourself.",
            };

            var source = new TwitterSource();

            var html = source.RenderHtml(status);

            Assert.AreEqual <string>("This is so cool <a href=\"http://www.twitter.com/#!/search?q=Dude\" target=\"_blank\">#Dude</a> check yourself.", html);
        }
Example #6
0
        public void RenderHtmlMention()
        {
            var status = new Status()
            {
                Text = "Hey @someone check this out!",
            };

            var source = new TwitterSource();

            var html = source.RenderHtml(status);

            Assert.AreEqual <string>("Hey @<a href=\"http://www.twitter.com/#!/someone\" target=\"_blank\">someone</a> check this out!", html);
        }
 public ActionResult CompanyTweets()
 {
     using (new PerformanceMonitor())
     {
         try
         {
             var source = new TwitterSource();
             return(this.Json(source.Employees(10), JsonRequestBehavior.AllowGet));
         }
         catch (Exception ex)
         {
             logger.Log(ex, EventTypes.Error, (int)Fault.Unknown);
             return(this.Json(WebResponse.Bind((int)Fault.Unknown, ex.Message), JsonRequestBehavior.AllowGet));
         }
     }
 }
Example #8
0
        public ActionResult Twitter()
        {
            using (new Service.PerformanceMonitor())
            {
                var user       = User.Identity.Data();
                var preference = new UserPreference()
                {
                    Application = Application.Current,
                    User        = user,
                };

                preference = userCore.Get(preference);
                var profile = new UserProfile()
                {
                    CreatedOn = user.CreatedOn,
                    Gravatar  = string.IsNullOrWhiteSpace(user.Email) ? null : user.Email.GetHexMD5(),
                    UserName  = user.UserName,
                    Email     = user.Email,
                    TimeZone  = preference.TimeZone,
                    MaximumAllowedApplications   = preference.MaximumAllowedApplications,
                    CurrentApplicationIdentifier = preference.CurrentApplication == null ? Guid.Empty : preference.CurrentApplication.Identifier,
                    TwitterHandle = preference.TwitterHandle,
                    AbcHandle     = preference.AbcHandle,
                    City          = preference.City,
                    Country       = preference.Country,
                    GitHubHandle  = preference.GitHubHandle,
                };

                if (!string.IsNullOrWhiteSpace(profile.TwitterHandle))
                {
                    try
                    {
                        var twitter = new TwitterSource();
                        profile.Tweets = twitter.ByUser(preference.TwitterHandle, 10).ToList();
                    }
                    catch (Exception ex)
                    {
                        log.Log(ex, EventTypes.Warning, (int)Fault.TwitterFailure);
                    }
                }

                this.ViewBag.Profiles = this.Profiles();

                return(View(profile));
            }
        }
        /// <summary>
        /// Default Page
        /// </summary>
        /// <remarks>
        /// GET: /
        /// </remarks>
        /// <returns>Action Result</returns>
        public ActionResult Index(string username)
        {
            if (!string.IsNullOrWhiteSpace(username))
            {
                var page = new ProfilePage()
                {
                    Handle = username,
                    ApplicationIdentifier = Application.Default.Identifier,
                };

                try
                {
                    var core = new UserCore();
                    page = core.Get(page);
                    if (null != page)
                    {
                        var user = new User()
                        {
                            Identifier = page.OwnerIdentifier,
                        };

                        var userApp = new UserApplication()
                        {
                            Application = Application.Default,
                            User        = user,
                        };

                        var userCore = new UserCore();
                        user = userCore.GetByIdentifier(userApp);
                        if (null != user)
                        {
                            var temp = user.Convert();
                            temp.Points = page.Points;
                            var publicProfile = temp.Convert();

                            var preference = new UserPreference()
                            {
                                Application = Application.Default,
                                User        = user,
                            };

                            preference = userCore.Get(preference);

                            publicProfile.Set(preference);

                            if (!string.IsNullOrWhiteSpace(publicProfile.TwitterHandle))
                            {
                                try
                                {
                                    var twitter = new TwitterSource();
                                    publicProfile.Tweets = twitter.ByUser(publicProfile.TwitterHandle, 10).ToList();
                                }
                                catch (Exception ex)
                                {
                                    logger.Log(ex, EventTypes.Warning, 999);
                                }
                            }

                            this.ViewBag.Gravatar      = publicProfile.Gravatar;
                            this.ViewBag.AbcHandle     = publicProfile.AbcHandle.ToLower();
                            this.ViewBag.GithubHandle  = publicProfile.GitHubHandle;
                            this.ViewBag.TwitterHandle = publicProfile.TwitterHandle;
                            return(this.View(publicProfile));
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Log(ex, EventTypes.Warning, 999);
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Example #10
0
        /// <summary>
        /// Default Page
        /// </summary>
        /// <remarks>
        /// GET: /
        /// </remarks>
        /// <returns>Action Result</returns>
        public ActionResult Index(string username)
        {
            using (new PerformanceMonitor())
            {
                if (!string.IsNullOrWhiteSpace(username))
                {
                    var page = new ProfilePage()
                    {
                        Handle = username,
                        ApplicationIdentifier = Application.Current.Identifier,
                    };

                    try
                    {
                        var core = new UserCore();
                        page = core.Get(page);
                        if (null != page)
                        {
                            var user = new User()
                            {
                                Identifier = page.OwnerIdentifier,
                            };

                            var userApp = new UserApplication()
                            {
                                Application = Application.Current,
                                User        = user,
                            };

                            var userCore = new UserCore();
                            user = userCore.GetByIdentifier(userApp);
                            if (null != user)
                            {
                                var publicProfile = user.Convert().Convert();

                                var preference = new UserPreference()
                                {
                                    Application = Application.Current,
                                    User        = user,
                                };

                                preference = userCore.Get(preference);

                                publicProfile.Set(preference);

                                if (!string.IsNullOrWhiteSpace(publicProfile.TwitterHandle))
                                {
                                    try
                                    {
                                        var twitter = new TwitterSource();
                                        publicProfile.Tweets = twitter.ByUser(publicProfile.TwitterHandle, 10).ToList();
                                    }
                                    catch (Exception ex)
                                    {
                                        log.Log(ex, EventTypes.Warning, (int)Fault.TwitterFailure);
                                    }
                                }
                                return(this.View(publicProfile));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Log(ex, EventTypes.Warning, (int)ServiceFault.Empty);
                    }
                }

                return(this.RedirectToAction("Index", "Home"));
            }
        }