Inheritance: System.Web.Mvc.AsyncController
        public void CanQueryFeedsInBulk()
        {
            var controller = new FeedController(_factory);
            var waitHandle = new AutoResetEvent(false);
            IFeedLocationService locationService = new FakeFeedLocationService();

            // Create and attach event handler for the "Finished" event
            EventHandler eventHandler = (sender, e) => waitHandle.Set();
            controller.AsyncManager.Finished += eventHandler;

            foreach(var item in locationService.GetFeeds())
            {
                if (_factory.PingFeed(item))
                {
                    controller.FeedAsync(item.AbsoluteUri, ItemCount);

                    const int msTimeout = 5000;
                    if (!waitHandle.WaitOne(msTimeout, false))
                    {
                        Assert.Fail("Test timed out.");
                    }

                    var response = controller.AsyncManager.Parameters["feed"] as IFeed;
                    Assert.IsNotNull(response);
                    Assert.AreEqual(item.AbsoluteUri, response.FeedUri.AbsoluteUri);
                    var summary = FeedSummarizer.SummarizeFeed(response, ItemCount);
                    Assert.AreEqual(summary.Items.Count, ItemCount);
                }
                else
                {
                    Assert.Inconclusive(string.Format("Unable to ping feed at uri {0}", item));
                }
            }
        }
        public void FeedAsyncMethodShouldPopulateAsyncParameters()
        {
            var controller = new FeedController(_factory);
            var waitHandle = new AutoResetEvent(false);
            // Create and attach event handler for the "Finished" event
            EventHandler eventHandler = (sender, e) => waitHandle.Set();
            controller.AsyncManager.Finished += eventHandler;

            if(_factory.PingFeed(new Uri(Feeduri)))
            {
                controller.FeedAsync(Feeduri, ItemCount);

                const int msTimeout = 5000;
                if (!waitHandle.WaitOne(msTimeout, false))
                {
                    Assert.Fail("Test timed out.");
                }

                var response = controller.AsyncManager.Parameters["feed"] as IFeed;
                Assert.IsNotNull(response);
                Assert.AreEqual(Feeduri, response.FeedUri.AbsoluteUri);
                Assert.IsTrue(response.Items.Count() > 0);
            }
            else
            {
                Assert.Inconclusive(string.Format("Unable to ping feed at uri {0}", Feeduri));
            }
        }
        public void FeedCompletedShouldReturnValidJsonObject()
        {
            var controller = new FeedController(_factory);
            IFeed feed = null;
            var serializer = new JavaScriptSerializer();
            JsonResult expected = null;
            JsonResult actual;

            if (_factory.PingFeed(new Uri(Feeduri)))
            {
                feed = _factory.CreateFeed(new Uri(Feeduri));
                var jsonExpected = serializer.Serialize(FeedSummarizer.SummarizeFeed(feed, ItemCount));

                Assert.IsNotNull(feed);
                Assert.AreEqual(Feeduri, feed.FeedUri.AbsoluteUri);

                actual = controller.FeedCompleted(feed, ItemCount);
                var jsonActual = serializer.Serialize(actual.Data);

                //The Guid ids are going to be different, but the lengths of the response should be the same
                Assert.AreEqual(jsonExpected.Length, jsonActual.Length);
                Assert.IsTrue(jsonActual.Length > 0); //Double check to see that we didn't manage to serialize anything
            }
            else
            {
                Assert.Inconclusive(string.Format("Unable to ping feed at uri {0}", Feeduri));
            }
        }