public async Task RetweetersAreLoaded()
        {
            // Arrange
            var status = DummyGenerator.CreateDummyStatus();

            status.ID = 123;

            var context = new Mock <IContextEntry>();

            context.Setup(c => c.Twitter.Search.SearchReplies(It.IsAny <Status>())).Returns(
                Task.FromResult(new List <Status>()));
            context.Setup(c => c.Twitter.Users.LookupUsers(It.IsAny <IEnumerable <ulong> >())).Returns(
                Task.FromResult(new List <UserEx>()));
            context.Setup(c => c.Twitter.Statuses.FindRetweeters(123, It.IsAny <int>())).Returns(
                Task.FromResult(new List <ulong>())).Verifiable();

            var statusVm = new StatusViewModel(status, context.Object, null, null);
            var vm       = new TweetDetailsViewModel
            {
                DisplayTweet = statusVm,
                Dispatcher   = new SyncDispatcher(),
                Context      = context.Object
            };

            // Act
            await vm.OnLoad(null);

            // Assert
            context.Verify(c => c.Twitter.Statuses.FindRetweeters(123, It.IsAny <int>()), Times.Once());
        }
        public async Task <ActionResult> GetTweet()
        {
            List <Tweet> list = new List <Tweet>();
            List <TweetDetailsViewModel> tweets = new List <TweetDetailsViewModel>();

            try
            {
                string Startdate = TempData["StartDate"].ToString();
                string Enddate   = TempData["EndDate"].ToString();

                TempData.Keep();



                string Baseurl = System.Configuration.ConfigurationManager.AppSettings["APIUrl"];
                using (var client = new HttpClient())
                {
                    //Passing service base url
                    client.BaseAddress = new Uri(Baseurl);

                    client.DefaultRequestHeaders.Clear();
                    //Define request data format
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    //Sending request to find web api REST service resource GetTweets using HttpClient
                    HttpResponseMessage Response = await client.GetAsync("api/v1/Tweets?startDate=" + Startdate + "&endDate=" + Enddate);

                    //Checking the response is successful or not which is sent using HttpClient
                    if (Response.IsSuccessStatusCode)
                    {
                        //Storing the response details recieved from web api
                        var TweetResponse = Response.Content.ReadAsStringAsync().Result;

                        //Deserializing the response recieved from web api and storing into the Tweet list
                        list = JsonConvert.DeserializeObject <List <Tweet> >(TweetResponse);
                        list = list.OrderBy(o => o.stamp).ToList();
                        var result = list.Distinct(new ItemEqualityComparer());

                        foreach (var item in result)
                        {
                            TweetDetailsViewModel objTweet = new TweetDetailsViewModel();
                            objTweet.Year  = DateTime.Parse(item.stamp.ToString()).Year;
                            objTweet.Month = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Parse(item.stamp.ToString()).Month);

                            objTweet.Day         = DateTime.Parse(item.stamp.ToString()).Day;
                            objTweet.Time        = DateTime.Parse(item.stamp.ToString()).TimeOfDay;
                            objTweet.Description = item.text;
                            tweets.Add(objTweet);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }
            return(View(tweets));
        }
        public void NotifyPropertyChangedIsImplementedCorrectly()
        {
            // Arrange
            var typeResolver = new Mock <ITypeResolver>();

            typeResolver.Setup(t => t.Resolve(typeof(StatusViewModel))).Returns(new StatusViewModel(DummyGenerator.CreateDummyStatus(), null, null, null));

            var vm     = new TweetDetailsViewModel();
            var tester = new PropertyChangedTester(vm, false, typeResolver.Object);

            // Act
            tester.Test(nameof(TweetDetailsViewModel.Context));

            // Assert
            tester.Verify();
        }
        public async Task LoadingWithoutTweetClosesDialog()
        {
            // Arrange
            var vm = new TweetDetailsViewModel
            {
                Dispatcher = new SyncDispatcher()
            };
            bool closed = false;

            vm.CloseRequested += (s, e) => closed = true;

            // Act
            await vm.OnLoad(null);

            // Assert
            Assert.IsTrue(closed);
        }
        public async Task PreviousTweetsInConversationAreLoaded()
        {
            // Arrange
            var s1 = DummyGenerator.CreateDummyStatus();

            s1.StatusID = 111;

            var s2 = DummyGenerator.CreateDummyStatus();

            s2.StatusID          = 222;
            s2.InReplyToStatusID = s1.StatusID;

            var s3 = DummyGenerator.CreateDummyStatus();

            s3.StatusID          = 333;
            s3.InReplyToStatusID = s2.StatusID;

            var context = new Mock <IContextEntry>();

            context.Setup(c => c.Twitter.Statuses.GetTweet(111, It.IsAny <bool>())).Returns(Task.FromResult(s1));
            context.Setup(c => c.Twitter.Statuses.GetTweet(222, It.IsAny <bool>())).Returns(Task.FromResult(s2));
            context.Setup(c => c.Twitter.Statuses.GetTweet(333, It.IsAny <bool>())).Returns(Task.FromResult(s3));
            context.Setup(c => c.Twitter.Search.SearchReplies(It.IsAny <Status>())).Returns(
                Task.FromResult(new List <Status>()));
            context.Setup(c => c.Twitter.Users.LookupUsers(It.IsAny <IEnumerable <ulong> >())).Returns(
                Task.FromResult(new List <UserEx>()));
            context.Setup(c => c.Twitter.Statuses.FindRetweeters(123, It.IsAny <int>())).Returns(
                Task.FromResult(new List <ulong>()));

            var statusVm = new StatusViewModel(s3, context.Object, null, null);
            var vm       = new TweetDetailsViewModel
            {
                Dispatcher   = new SyncDispatcher(),
                Context      = context.Object,
                DisplayTweet = statusVm
            };

            // Act
            await vm.OnLoad(null);

            // Assert
            Assert.AreEqual(2, vm.PreviousConversationTweets.Count);
            Assert.AreEqual(111ul, vm.PreviousConversationTweets[0].Id);
            Assert.AreEqual(222ul, vm.PreviousConversationTweets[1].Id);
        }