public void a_connectivity_exception_will_be_thrown_if_the_uri_isnt_resolveable()
 {
     Assert.Throws <FetchException>(() =>
     {
         var fetcher = new BuildDataFetcher(
             new ViewUrl("http://a.b.c.d.e.foo/ccnet/XmlStatusReport.aspx"),
             _configSettings, _factory);
         fetcher.Fetch();
     }, "Unable to contact http://a.b.c.d.e.foo/ccnet/XmlStatusReport.aspx");
 }
        public void CanFetch()
        {
            const string Hello = "hello";

            _webClient.Expect(w => w.DownloadString(Arg <string> .Is.Anything)).Return(Hello);

            var fetcher    = new BuildDataFetcher(new ViewUrl("http://test"), new ConfigSettings(), _webClientFactory);
            var fetchValue = fetcher.Fetch();

            fetchValue.First().ShouldBe(Hello);
        }
        public void can_get_projects_from_a_realaddress()
        {
            var fetcher =
                new BuildDataFetcher(new ViewUrl("http://ccnetlive.thoughtworks.com/ccnet/XmlStatusReport.aspx"),
                                     _configSettings, _factory);

            var fetch = fetcher.Fetch().ToList();

            fetch.Count().ShouldBeGreaterThan(0);
            fetch.ShouldContain(@"Project name=""CCNet""");
        }
        public void can_fetch_multiple_urls()
        {
            _webClient.Expect(w => w.DownloadString(Arg <string> .Is.Anything)).Return("url1").Repeat.Once();
            _webClient.Expect(w => w.DownloadString(Arg <string> .Is.Anything)).Return("url2").Repeat.Once();

            var fetcher = new BuildDataFetcher(new ViewUrl("http://url1 http://url2"),
                                               new ConfigSettings(), _webClientFactory);

            var xmlResults = fetcher.Fetch().ToList();

            xmlResults.Count.ShouldBe(2);
            xmlResults[0].ShouldBe("url1");
            xmlResults[1].ShouldBe("url2");

            _webClient.AssertWasCalled(w => w.DownloadString(Arg <string> .Is.Equal(new Uri("http://url1"))));
            _webClient.AssertWasCalled(w => w.DownloadString(Arg <string> .Is.Equal(new Uri("http://url2"))));
        }
        public void CanUpdateSettings()
        {
            var fetcher = new BuildDataFetcher(new ViewUrl("http://bla"),
                                               new ConfigSettings
            {
                URL = "http://bla"
            }, _webClientFactory);

            fetcher.Fetch();
            _webClient.AssertWasCalled(w => w.DownloadString(Arg <string> .Is.Equal(new Uri("http://bla"))), w => w.Repeat.Once());

            fetcher.ConfigUpdated(new ConfigSettings {
                URL = "http://new"
            });
            fetcher.Fetch();
            _webClient.AssertWasCalled(w => w.DownloadString(Arg <string> .Is.Equal(new Uri("http://new"))), w => w.Repeat.Once());
        }