public void Initialise()
        {
            ObjectSerializer        = new Mock <IObjectSerializer>();
            SentimentRequestFactory = new Mock <ISentimentRequestFactory>();
            HttpHelper = new Mock <IHttpHelper>();

            SentimentApiAdapter = new SentimentApiAdapter(
                ObjectSerializer.Object,
                SentimentRequestFactory.Object,
                HttpHelper.Object);
        }
Beispiel #2
0
        public void Setup()
        {
            Initialise();

            _tweet = TweetBuilder.Build.AnInstance();

            _sentimentReponse = SentimentResponseBuilder.Build.AnInstance();
            SentimentApiAdapter
            .Setup(x => x.GetSentiment(_tweet))
            .Returns(Task.FromResult(_sentimentReponse));

            _sentimentTweet = SentimentTweetBuilder.Build.AnInstance();
            SentimentTweetMapper
            .Setup(x => x.MapFor(_sentimentReponse, _tweet))
            .Returns(_sentimentTweet);

            _result = Controller.GetSentiment(_tweet).Result;
        }
        public void Setup()
        {
            Initialise();

            _tweet = TweetBuilder.Build.WithText("1").AnInstance();

            _httpRequest = new Mock <HttpWebRequest>();
            SentimentRequestFactory
            .Setup(x => x.CreateSentimentForTweetRequest(_tweet))
            .Returns(_httpRequest.Object);

            _httpResponse = new Mock <HttpWebResponse>();
            HttpHelper
            .Setup(x => x.GetResponse(_httpRequest.Object))
            .Returns(Task.FromResult(_httpResponse.Object));

            _sentimentResponse = SentimentResponseBuilder.Build.WithScore(1.0).AnInstance();
            ObjectSerializer
            .Setup(x => x.DeserializeJson <SentimentResponse>(_httpResponse.Object))
            .Returns(_sentimentResponse);

            _result = SentimentApiAdapter.GetSentiment(_tweet).Result;
        }
Beispiel #4
0
 public void ItShouldGetSentimentFromService()
 {
     SentimentApiAdapter.Verify(x => x.GetSentiment(_tweet));
 }