public void SuccessfulSearchCausesListToBeBroadcast() { ClearAll(); CreateMockNavigation(); var twitterService = new Mock <ITwitterSearchProvider>(); var searchText = "To search for"; Action <IEnumerable <Tweet> > storedSuccessAction = null; Action <Exception> storedErrorAction = null; twitterService.Setup(x => x.StartAsyncSearch(It.Is <string>(s => s == searchText), It.IsAny <Action <IEnumerable <Tweet> > >(), It.IsAny <Action <Exception> >())) .Callback((string s, Action <IEnumerable <Tweet> > suc, Action <Exception> err) => { storedSuccessAction = suc; storedErrorAction = err; }); var viewModel = new TwitterViewModel(twitterService.Object); viewModel.Init(searchText); var list = new List <Tweet>() { new Tweet() { } }; storedSuccessAction(list); Assert.IsNotNull(viewModel.Tweets); Assert.AreEqual(1, viewModel.Tweets.Count()); }
public void TwitterSearch_Error_Callback_Clears_IsSearching() { using (var setup = new MockSetup()) { setup.Initialize(); string search = null; Action <IEnumerable <Tweet> > success = null; Action <Exception> error = null; setup .Twitter .Setup(x => x.StartAsyncSearch(It.IsAny <string>(), It.IsAny <Action <IEnumerable <Tweet> > >(), It.IsAny <Action <Exception> >())) .Callback <string, Action <IEnumerable <Tweet> >, Action <Exception> >((s, s2, e) => { search = s; success = s2; error = e; }); var viewModel = new TwitterViewModel("mySearchTerm"); var calledChanges = new List <string>(); viewModel.PropertyChanged += (s, a) => calledChanges.Add(a.PropertyName); error(new Exception("Test exception")); Assert.AreEqual(1, calledChanges.Count); CollectionAssert.Contains(calledChanges, "IsSearching"); Assert.IsFalse(viewModel.IsSearching); Assert.IsNull(viewModel.Tweets); } }
public JsonResult GetCityTweets(string cityName) { TwitterViewModel model = new TwitterViewModel { ProfileName = string.Empty, FollowerCount = 0, FollowingCount = 0, TweetList = new List <TweetViewModel>() }; var searchParameter = new TweetSearchParameters("") { Lang = Language.English, //hard coding the geo location for newyork GeoCode = Geo.GenerateGeoCode(Geo.GenerateCoordinates(-74.006, 40.742), 1000, DistanceMeasure.Miles) }; var tweets = Search.SearchTweets(searchParameter); foreach (var item in tweets.OrderByDescending(res => res.CreatedAt)) { model.TweetList.Add(new TweetViewModel { TweetText = item.Text, CreatedAt = String.Format("{0:d/M/yyyy HH:mm:ss}", item.CreatedAt), CreatedBy = item.CreatedBy.Id.ToString(), HashTag = item.Hashtags.Any() ? item.Hashtags[0].Text : "" }); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public void Init() { var tweets = new ObservableCollection <Tweet>() { new Tweet { created_at = "1/1/2012", entities = new TwitterUserEntities { media = new List <TwitterUserMedia>() { new TwitterUserMedia { media_url = "http://www.google.com/google.jpg" }, }, }, text = "Tweet from RealTimeWWII", user = new TwitterUser { screen_name = "RealTimeWWII", name = "Real Tweets From WWII", profile_image_url = "http://www.twitter.com/twitter.jpg" }, } }; _mock = MockRepository.GenerateMock <ITwitterService>(); _mock.Stub(s => s.GetNextTwentyTweetsFromUserId("RealTimeWWII")).Return(tweets); _tvm = new TwitterViewModel(_mock); }
public TwitterPage() { InitializeComponent(); BindingContext = new TwitterViewModel(); listView.ItemTapped += async(sender, args) => { if (listView.SelectedItem == null) { return; } var tweet = listView.SelectedItem as Tweet; //try to launch twitter or tweetbot app, else launch browser var launch = DependencyService.Get <ILaunchTwitter>(); if (launch == null || !launch.OpenStatus(tweet.StatusID.ToString())) { await Browser.OpenAsync("http://twitter.com/shanselman/status/" + tweet.StatusID); } listView.SelectedItem = null; }; }
public void TwitterSearch_Success_Callback_Sets_Tweets() { using (var setup = new MockSetup()) { setup.Initialize(); string search = null; Action <IEnumerable <Tweet> > success = null; Action <Exception> error = null; setup .Twitter .Setup(x => x.StartAsyncSearch(It.IsAny <string>(), It.IsAny <Action <IEnumerable <Tweet> > >(), It.IsAny <Action <Exception> >())) .Callback <string, Action <IEnumerable <Tweet> >, Action <Exception> >((s, s2, e) => { search = s; success = s2; error = e; }); var viewModel = new TwitterViewModel("mySearchTerm"); var calledChanges = new List <string>(); viewModel.PropertyChanged += (s, a) => calledChanges.Add(a.PropertyName); var result = new[] { new Tweet(), new Tweet() }; success(result); Assert.AreEqual(2, calledChanges.Count); CollectionAssert.Contains(calledChanges, "Tweets"); Assert.AreEqual(2, viewModel.Tweets.Count()); CollectionAssert.Contains(viewModel.Tweets.ToList(), result[0]); CollectionAssert.Contains(viewModel.Tweets.ToList(), result[1]); } }
public void TwitterSearch_Constructor_Requests_A_TwitterSearch() { using (var setup = new MockSetup()) { setup.Initialize(); string search = null; Action <IEnumerable <Tweet> > success = null; Action <Exception> error = null; setup .Twitter .Setup(x => x.StartAsyncSearch(It.IsAny <string>(), It.IsAny <Action <IEnumerable <Tweet> > >(), It.IsAny <Action <Exception> >())) .Callback <string, Action <IEnumerable <Tweet> >, Action <Exception> >((s, s2, e) => { search = s; success = s2; error = e; }); var viewModel = new TwitterViewModel("mySearchTerm"); setup .Twitter .Verify(x => x.StartAsyncSearch(It.IsAny <string>(), It.IsAny <Action <IEnumerable <Tweet> > >(), It.IsAny <Action <Exception> >()), Times.Once()); Assert.AreEqual("mySearchTerm", search); Assert.IsNotNull(success); Assert.IsNotNull(error); } }
public TweetsView(string ticker) { InitializeComponent(); var viewModel = new TwitterViewModel(ticker); BindingContext = viewModel; viewModel.LoadTweetsCommand(); TweetList.ItemSelected += (sender, args) => { if (TweetList.SelectedItem == null) { return; } Navigation.PushAsync(new ContentPage { Content = new WebView { Source = new UrlWebViewSource { Url = ((Tweet)TweetList.SelectedItem).Url } } }); TweetList.SelectedItem = null; }; }
public TwitterPage() { InitializeComponent(); ListTweets.RowHeight = Device.OnPlatform <int>(110, 110, 150); this.BindingContext = viewModel = new TwitterViewModel(); }
public HomeViewModel() { Welcome = new WelcomeViewModel(); Sessions = new SessionsViewModel(); Twitter = new TwitterViewModel(); Favorites = new FavoritesViewModel(); }
public void SuccessfulSearchCausesChangeInIsSearching() { CreateMockNavigation(); var twitterService = new Mock <ITwitterSearchProvider>(); Ioc.RegisterServiceInstance <ITwitterSearchProvider>(twitterService.Object); var searchText = "To search for"; Action <IEnumerable <Tweet> > storedSuccessAction = null; Action <Exception> storedErrorAction = null; twitterService.Setup(x => x.StartAsyncSearch(It.Is <string>(s => s == searchText), It.IsAny <Action <IEnumerable <Tweet> > >(), It.IsAny <Action <Exception> >())) .Callback((string s, Action <IEnumerable <Tweet> > suc, Action <Exception> err) => { storedSuccessAction = suc; storedErrorAction = err; }); var viewModel = new TwitterViewModel(searchText); var list = new List <Tweet>() { new Tweet() { } }; storedSuccessAction(list); Assert.IsFalse(viewModel.IsSearching); }
public void GetNextTwentyTweetsFromUserIdShouldReturnObservableContainerThatContainsInvalidTwitterID() { var tv = new TwitterViewModel(); tv.UpdateTweets("____INVALID"); Assert.IsTrue(tv.Tweets.First().text == "Invalid TwitterID."); }
public void ShouldGetNextTwentyTweetsFromUserId() { var tv = new TwitterViewModel(); tv.UpdateTweets("RealTimeWWII"); Assert.IsTrue(tv.Tweets.Count == 20); }
public TweetsView(string ticker) { InitializeComponent(); viewModel = new TwitterViewModel(ticker); // Assign the async function here, so we can await correctly InitializeTweets = InitializeAsync(); }
public TwitterWindow(bool auth) { InitializeComponent(); AuthKaijoButton.IsEnabled = auth; TwitterViewModel vm = new TwitterViewModel(); this.DataContext = vm; }
public TwitterList() { this.InitializeComponent(); _navigationHelper = new NavigationHelper(this); TwitterModel = new TwitterViewModel(); SizeChanged += OnSizeChanged; }
public TwitterPage() { this.InitializeComponent(); _navigationHelper = new NavigationHelper(this); TwitterModel = new TwitterViewModel(); DataContext = this; SizeChanged += OnSizeChanged; }
public void TwitterSearch_Constructor_Sets_IsSearching_True() { using (var setup = new MockSetup()) { setup.Initialize(); var viewModel = new TwitterViewModel("mySearchTerm"); Assert.IsTrue(viewModel.IsSearching); } }
public JsonResult GetUserDetails(string id, string key, string geo) { string message = ""; TwitterViewModel model = new TwitterViewModel { TweetList = new List <TweetViewModel>() }; if (!string.IsNullOrEmpty(id)) { var user = Tweetinvi.User.GetUserFromScreenName(id); model.ProfileName = user.Name; model.FollowerCount = user.FollowersCount; model.FollowingCount = user.FriendsCount; } string query = string.IsNullOrEmpty(key) ? "" : key + " "; query += string.IsNullOrEmpty(id) ? "" : "from:" + id; var searchParameter = new TweetSearchParameters("") { Lang = Language.English, SearchQuery = query.TrimEnd() }; if (!string.IsNullOrEmpty(geo)) { string[] result = geo.Split(','); if (!string.IsNullOrEmpty(result[0].Trim())) { searchParameter.GeoCode = new GeoCode(double.Parse(result[1].TrimEnd()), double.Parse(result[0].TrimEnd()), double.Parse(result[2].TrimEnd()), DistanceMeasure.Miles); } } var tweets = Search.SearchTweets(searchParameter); foreach (var item in tweets.OrderByDescending(res => res.CreatedAt)) { model.TweetList.Add(new TweetViewModel { TweetText = item.Text, CreatedAt = String.Format("{0:d/M/yyyy HH:mm:ss}", item.CreatedAt), CreatedBy = item.CreatedBy.Name, HashTag = item.Hashtags.Any() ? item.Hashtags[0].Text : "" }); } return(Json(model, JsonRequestBehavior.AllowGet)); }
async void HandleMessage(IMessageEvent message) { try { Android.Util.Log.Info("WearIntegration", "Received Message"); var client = new GoogleApiClientBuilder(this) .AddApi(WearableClass.Api) .Build(); var result = client.BlockingConnect(30, Java.Util.Concurrent.TimeUnit.Seconds); if (!result.IsSuccess) { return; } var path = message.Path; try { if (path.StartsWith(TweetsPath)) { var viewModel = new TwitterViewModel(); await viewModel.ExecuteLoadTweetsCommand(); var request = PutDataMapRequest.Create(TweetsPath + "/Answer"); var map = request.DataMap; var tweetMap = new List <DataMap>(); foreach (var tweet in viewModel.Tweets) { var itemMap = new DataMap(); itemMap.PutLong("CreatedAt", tweet.CreatedAt.Ticks); itemMap.PutString("ScreenName", tweet.ScreenName); itemMap.PutString("Text", tweet.Text); tweetMap.Add(itemMap); } map.PutDataMapArrayList("Tweets", tweetMap); map.PutLong("UpdatedAt", DateTime.UtcNow.Ticks); WearableClass.DataApi.PutDataItem(client, request.AsPutDataRequest()); } } finally { client.Disconnect(); } } catch (Exception e) { Android.Util.Log.Error("WearIntegration", e.ToString()); } }
// GET: Twitter Feeds public ActionResult TwitterFeed() { var twitterSettings = Sitecore.Context.Database.GetItem("/sitecore/content/Home/Twitter Settings"); var twitterViewModel = new TwitterViewModel() { Tweets = GetTweets(twitterSettings) }; return(View(twitterViewModel)); }
public void ConstructionStartsSearch() { var twitterService = new Mock <ITwitterSearchProvider>(); Ioc.RegisterServiceInstance <ITwitterSearchProvider>(twitterService.Object); var searchText = "To search for"; var viewModel = new TwitterViewModel(searchText); Assert.IsTrue(viewModel.IsSearching); twitterService.Verify(x => x.StartAsyncSearch(It.Is <string>(s => s == searchText), It.IsAny <Action <IEnumerable <Tweet> > >(), It.IsAny <Action <Exception> >()), Times.Once()); }
public TwitterPage() { this.InitializeComponent(); _navigationHelper = new NavigationHelper(this); TwitterModel = new TwitterViewModel(); DataContext = this; ApplicationView.GetForCurrentView(). SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible); }
public override void AwakeFromNib() { base.AwakeFromNib(); viewModel = new TwitterViewModel(); Search.EditingEnded += OnLoadPressed; LoadTweets.Activated += OnLoadPressed; TweetTable.WeakDataSource = this; TweetTable.WeakDelegate = this; TweetTable.HeaderView = null; }
public TwitterPage() { InitializeComponent(); VM = BindingContext as TwitterViewModel; service = new TwitterService(Key, Secret, AccessToken, AccessTokenSecret); TwitterStatus CurrentTweet = SendTweet("Hello World"); TweetsToDelete.Add(CurrentTweet); tweets = GetTweetsFromHome(); foreach (TwitterStatus tweet in tweets) { VM.TweetsPickerSource.Add(tweet.Text); } }
private void Button_Click(object sender, RoutedEventArgs e) { this.list = new List <TweetInfo>(); TwitterViewModel viewmodel = new TwitterViewModel(); list = viewmodel.Get(textbox.Text); List <KeyValuePair <string, string> > temp = new List <KeyValuePair <string, string> >(); foreach (var item in list) { temp.Add(new KeyValuePair <string, string>(item.Username, item.Tweet)); } listbox.ItemsSource = temp; }
public Twitter() { InitializeComponent(); BindingContext = new TwitterViewModel(); var htmlSource = new HtmlWebViewSource(); //htmlSource.Html = @"<html><body> // <h1>Twitter Feed</h1> // <p>ILCE</p> // <a class='twitter - timeline' href='https://mobile.twitter.com/ILCEedu'>Twitter ILCE</a> // <script async src = 'https://platform.twitter.com/widgets.js' charset = 'utf-8' ></ script > // </body></html>"; //TwitterWebView.Source = htmlSource; TwitterWebView.Source = "https://mobile.twitter.com/ILCEedu"; }
public TwitterPage() { InitializeComponent(); BindingContext = new TwitterViewModel(); listView.ItemTapped += (sender, args) => { if (listView.SelectedItem == null) return; var tweet = listView.SelectedItem as Tweet; this.Navigation.PushAsync(new WebsiteView("http://m.twitter.com/shanselman/status/" + tweet.StatusID, tweet.Date)); listView.SelectedItem = null; }; }
public IActionResult GetHomeTimeline() { TwitterViewModel homeView = new TwitterViewModel(); try { if (config.TwitterConfiguration.Access_Token == null) { throw new Tweetinvi.Exceptions.TwitterNullCredentialsException(); } if (config.TwitterConfiguration.Access_Secret == null) { throw new Tweetinvi.Exceptions.TwitterNullCredentialsException(); } var userCredentials = Auth.CreateCredentials( config.TwitterConfiguration.Consumer_Key , config.TwitterConfiguration.Consumer_Secret , config.TwitterConfiguration.Access_Token , config.TwitterConfiguration.Access_Secret); var authenticatedUser = Tweetinvi.User.GetAuthenticatedUser(userCredentials); IEnumerable <ITweet> twitterFeed = authenticatedUser.GetHomeTimeline(config.TweetFeedLimit); List <TweetItem> tweets = new List <TweetItem>(); foreach (ITweet tweet in twitterFeed) { TweetItem tweetItem = new TweetItem(); tweetItem.Url = tweet.Url; tweets.Add(tweetItem); } homeView.HomeTimelineTweets = tweets; } catch (Tweetinvi.Exceptions.TwitterNullCredentialsException ex) { return(RedirectToAction("AuthenticateTwitter")); } catch (Exception ex) { } return(View("Views/Twitter/HomeTimeline.cshtml", homeView)); }
public TwitterPage() { InitializeComponent(); BindingContext = new TwitterViewModel(); listView.ItemTapped += (sender, args) => { if (listView.SelectedItem == null) { return; } var tweet = listView.SelectedItem as Tweet; this.Navigation.PushAsync(new WebsiteView("http://m.twitter.com/shanselman/status/" + tweet.StatusID, tweet.Date)); listView.SelectedItem = null; }; }
public void Setup() { _repo = MockRepository.GenerateMock <ITwitterRepository>(); // Stub list to return when GetAll or GetPredicate is called var list = new List <TweetFromUser>() { new TweetFromUser { TweetText = "This is my tweet", User = new User { Name = "mark" } }, new TweetFromUser { TweetText = "This is Tom's tweet" , User = new User { Name = "Tom" } }, new TweetFromUser { TweetText = "This is another tweet" , User = new User { Name = "mark" } } }; _repo.Stub(d => d.GetAll()).Return(list); // when they use UserName == "mark" // _repo.Stub(d => d.GetTweetsByScreenName("mark")).Return(list.Where(d => d.User.Name == "mark")); _vm = new TwitterViewModel(_repo); }
public TwitterSettingsViewModel(TwitterViewModel viewModel) { SearchStringIsNotNull(); ViewModel = viewModel; Search = new DelegateCommand {CanExecuteDelegate = CanSearchOrSave}; Save.CanExecuteDelegate = CanSearchOrSave; ReloadSettings.CanExecuteDelegate = CanReloadSettings; }
public void Setup() { _guid = Guid.NewGuid(); _timerMock = new Mock<ITimer>(); _progressbarMock = new Mock<IProgressbar>(); CreateTweetFetcherMock(MakeTwitterSearchResult(20)); defaultConfiguration = TwitterController.GetDefaultConfiguration(); _twitterViewModel = new TwitterViewModel(); _twitterSettingsViewModel = new TwitterSettingsViewModel(_twitterViewModel); CreateController(); Before(); }
public void Setup() { _twitterViewModel = new TwitterViewModel(); }