protected override void Given()
 {
     base.Given();
     StatusService = new Mock<IStatusService>();
     StatusService.Setup(ss => ss.GetUser("trasa")).Returns(new UserInfo
                                                                {
                                                                    Name = "trasa",
                                                                    FollowerCount = 1,
                                                                    FriendCount = 1,
                                                                    Location = "location",
                                                                });
     RequestQueue = new Mock<ITwitterRequestQueue>();
     ResponseQueue = new TwitterResponseQueueStub();
     CrawlerUnderTest = new TwitterCrawler(RequestQueue.Object, ResponseQueue, StatusService.Object);
 }
        public void ErrorResponse_Is_Queued()
        {
            // arrange
            var requestQueue = new MockRequestQueue();
            var responseQueue = new MockResponseQueue();
            var statusService = new Mock<IStatusService>();

            statusService.Setup(ss => ss.GetFriendsOf("test")).Throws(new XmlException("Twitter is full of FAIL!"));
            var crawler = new TwitterCrawler(requestQueue, responseQueue, statusService.Object);

            // act
            var friendRequest = new GetFriendsRequest("test");
            crawler.ProcessRequest(friendRequest);

            // assert
            Assert.That(responseQueue.QueuedMessages, Has.Count(1));
            Assert.That(responseQueue.QueuedMessages.Single(), Is.TypeOf(typeof(ErrorResponse)));
            var response = (ErrorResponse)responseQueue.QueuedMessages.Single();
            Assert.That(response.Request, Is.SameAs(friendRequest));
        }