Ejemplo n.º 1
0
        public void RequestNonExistentWebsiteThrowsContentNotFoundException()
        {
            this.IgnoreWhenInternetConnectionIsNotAvailable();

            var uri = new Uri("http://www.silkveil.netxxx");
            var httpContentSource = new HttpContentSource();

            Assert.That(() => httpContentSource.Request(uri), Throws.Exception.TypeOf(typeof(ContentNotFoundException)));
        }
Ejemplo n.º 2
0
        public void RequestNonExistentWebsiteThrowsContentNotFoundException()
        {
            this.IgnoreWhenInternetConnectionIsNotAvailable();

            var uri = new Uri("http://www.silkveil.netxxx");
            var httpContentSource = new HttpContentSource();

            Assert.That(() => httpContentSource.Request(uri), Throws.Exception.TypeOf(typeof(ContentNotFoundException)));
        }
Ejemplo n.º 3
0
        public void RequestWithWrongProtocol()
        {
            var uri = new Uri("file://C:/Foo.Bar");
            var httpContentSource = new HttpContentSource();

            var called = 0;
            httpContentSource.ContentAvailable += stream => called++;

            httpContentSource.Request(uri);

            Assert.That(called, Is.EqualTo(0));
        }
Ejemplo n.º 4
0
        public void RequestWithWrongProtocol()
        {
            var uri = new Uri("file://C:/Foo.Bar");
            var httpContentSource = new HttpContentSource();

            var called = 0;

            httpContentSource.ContentAvailable += stream => called++;

            httpContentSource.Request(uri);

            Assert.That(called, Is.EqualTo(0));
        }
Ejemplo n.º 5
0
        public void RequestWebsite()
        {
            this.IgnoreWhenInternetConnectionIsNotAvailable();

            var uri = new Uri("http://www.silkveil.net");
            const string content = "silkveil.net";
            var httpContentSource = new HttpContentSource();

            int count = 0;
            httpContentSource.ContentAvailable += stream =>
                                                      {
                                                          using (var streamReader = new StreamReader(stream))
                                                          {
                                                              count++;
                                                              Assert.That(streamReader.ReadToEnd(), Contains.Substring(content));
                                                          }
                                                      };
            httpContentSource.Request(uri);

            Assert.That(count, Is.EqualTo(1));
        }
Ejemplo n.º 6
0
        public void RequestWebsite()
        {
            this.IgnoreWhenInternetConnectionIsNotAvailable();

            var          uri               = new Uri("http://www.silkveil.net");
            const string content           = "silkveil.net";
            var          httpContentSource = new HttpContentSource();

            int count = 0;

            httpContentSource.ContentAvailable += stream =>
            {
                using (var streamReader = new StreamReader(stream))
                {
                    count++;
                    Assert.That(streamReader.ReadToEnd(), Contains.Substring(content));
                }
            };
            httpContentSource.Request(uri);

            Assert.That(count, Is.EqualTo(1));
        }