Inheritance: IConfigObserver
        public void can_get_projects_from_a_realaddress()
        {
            var fetcher =
                new BuildDataFetcher(new CruiseAddress("http://ccnetlive.thoughtworks.com/ccnet/XmlStatusReport.aspx"),
                                     _configSettings, _factory);

            Assert.That(fetcher.Fetch().Length, Is.GreaterThan(0));
            Assert.That(fetcher.Fetch(), Text.Contains("Ivy").IgnoreCase);
        }
        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();
            fetch.Count().ShouldBeGreaterThan(0);
            fetch.ShouldContain(@"Project name=""CCNet""");
        }
        public void a_connectivity_exception_will_be_thrown_if_the_uri_isnt_resolveable()
        {
            Assert.Throws<FetchException>(() =>
                                          {
                                          	var fetcher = new BuildDataFetcher(
                                          		new CruiseAddress("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<Uri>.Is.Anything)).Return(Hello);

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

            Assert.That(fetchValue, Is.EqualTo(Hello));
        }
Exemplo n.º 5
0
        public void CanUpdateSettings()
        {
            var fetcher = new BuildDataFetcher(new CruiseAddress("http://bla"), new ConfigSettings { URL = "http://bla" }, _webClientFactory);
            fetcher.Fetch();
            _webClient.AssertWasCalled(w => w.DownloadString(new Uri("http://bla")), w=>w.Repeat.Once());
            _webClient.AssertWasNotCalled(w => w.DownloadString(new Uri("http://new")));

            fetcher.ConfigUpdated(new ConfigSettings { URL = "http://new"});
            fetcher.Fetch();
            _webClient.AssertWasCalled(w => w.DownloadString(new Uri("http://new")), w=>w.Repeat.Once());
        }
        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_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"))));
        }
Exemplo n.º 8
0
        public ScreenUpdater(ICradiatorView view, DiscJockey discJockey,
							 ICountdownTimer countdownTimer, IPollTimer pollTimer,
		                     BuildDataFetcher buildDataFetcher, BuildDataTransformer buildDataTransformer,
		                     FetchExceptionHandler fetchExceptionHandler, BackgroundWorker worker)
        {
            _view = view;
            _discJockey = discJockey;
            _countdownTimer = countdownTimer;
            _pollTimer = pollTimer;
            _pollTimer.Tick = (sender, e) => Update();
            _fetcher = buildDataFetcher;
            _fetchExceptionHandler = fetchExceptionHandler;
            _transformer = buildDataTransformer;

            _worker = worker;
            worker.RunWorkerCompleted += DataFetched;
            worker.DoWork += FetchData;
        }
Exemplo n.º 9
0
        public ScreenUpdater(ICradiatorView view, DiscJockey discJockey, ICountdownTimer countdownTimer,
            IPollTimer pollTimer, IConfigSettings configSettings,
            BuildDataFetcher buildDataFetcher, BuildDataTransformer transformer,
            FetchExceptionHandler fetchExceptionHandler, BackgroundWorker worker)
        {
            _view = view;
            _discJockey = discJockey;
            _countdownTimer = countdownTimer;
            _pollTimer = pollTimer;
            _configSettings = configSettings;
            _pollTimer.Tick = (sender, e) => PollTimeup();
            _fetcher = buildDataFetcher;
            _fetchExceptionHandler = fetchExceptionHandler;
            _transformer = transformer;

            SetLocalValuesFromConfig(configSettings);

            _configSettings.AddObserver(this);

            _worker = worker;
            worker.DoWork += FetchData;
            worker.RunWorkerCompleted += DataFetched;
        }
Exemplo n.º 10
0
        public ScreenUpdater(ICradiatorView view, DiscJockey discJockey, ICountdownTimer countdownTimer,
                             IPollTimer pollTimer, IConfigSettings configSettings,
                             BuildDataFetcher buildDataFetcher, BuildDataTransformer transformer,
                             FetchExceptionHandler fetchExceptionHandler, BackgroundWorker worker)
        {
            _view                  = view;
            _discJockey            = discJockey;
            _countdownTimer        = countdownTimer;
            _pollTimer             = pollTimer;
            _configSettings        = configSettings;
            _pollTimer.Tick        = (sender, e) => PollTimeup();
            _fetcher               = buildDataFetcher;
            _fetchExceptionHandler = fetchExceptionHandler;
            _transformer           = transformer;

            SetLocalValuesFromConfig(configSettings);

            _configSettings.AddObserver(this);

            _worker                    = worker;
            worker.DoWork             += FetchData;
            worker.RunWorkerCompleted += DataFetched;
        }
 public void CanThrow_If_Invalid()
 {
     var fetcher = new BuildDataFetcher(new CruiseAddress(""), new ConfigSettings(), _webClientFactory);
     Assert.Throws<FetchException>(() => fetcher.Fetch());
 }