Exemplo n.º 1
0
 public void Posting_file_should_log_info_if_success()
 {
     var log = MockRepository.GenerateStub<ILog>();
     var xmlPoster = MockRepository.GenerateStub<IHttpPoster>();
     xmlPoster.Stub(x => x.Post(Arg<string>.Is.Anything)).Return("Post Added");
     var solrPoster = new SolrPoster<Song>(log, xmlPoster);
     solrPoster.PostToSolr(new Song());
     log.AssertWasCalled(x => x.Info("Post Added"));
 }
Exemplo n.º 2
0
        public void Posting_file_should_log_error_if_exception()
        {
            var log = MockRepository.GenerateStub<ILog>();
            var xmlPoster = MockRepository.GenerateStub<IHttpPoster>();
            xmlPoster.Stub(x => x.Post(Arg<string>.Is.Anything)).Throw(new Exception());

            var solrPoster = new SolrPoster<Song>(log, xmlPoster);
            solrPoster.PostToSolr(new Song());
            log.AssertWasCalled(x => x.Error("There was an error"));
        }
Exemplo n.º 3
0
        public void Item_is_added_to_solr_instance()
        {
            Given_a_single_song();
            Given_an_xml_web_request_to_solr_instance();

            var wrapper = new WebRequestWrapper(_webRequest);
            var httpPoster = new HttpPoster(wrapper);
            var solrPoster = new SolrPoster<Song>(httpPoster);

            string response = solrPoster.PostToSolr(_currentSong);

            Assert.That(response.ToLower(), Contains.Substring("<response>"));

            var solrResponse = new SolrResponse(response);

            Assert.That(solrResponse, Is.Not.Null);
            Assert.That(solrResponse.Status, Is.EqualTo(0));
        }
Exemplo n.º 4
0
 public void SuccessCtor()
 {
     var xmlPoster = MockRepository.GenerateStub<IHttpPoster>();
     var solrPoster = new SolrPoster<Song>(xmlPoster);
     Assert.That(solrPoster, Is.Not.Null);
 }