예제 #1
0
        public void DashboardHttpConstructorTest_Success()
        {
            // arrange
            FeedConfiguration dashboardConfiguration = new FeedConfiguration(null);
            Uri getUri = new Uri(dashboardConfiguration.DefaultUri);

            // act
            DashboardHttp target = new DashboardHttp(getUri);

            // assert
            Assert.IsNotNull(target);
        }
예제 #2
0
        /// <summary>
        /// Serialize RssFeeds to disk. Make request across
        /// wire to Uri, grab response into RssFeeds,
        /// serialize RssFeeds.
        /// </summary>
        /// <param name="pathToFiles">Path to serialized files</param>
        public void SetRssFeedsFromUri(string pathToFiles)
        {
            DashboardHttp httpRequest = new DashboardHttp();

            UriDatasource uriDataSource = new UriDatasource(httpRequest, this.httpContext);
            RssFeeds feeds = uriDataSource.Get();

            if (feeds == null)
            {
                throw new Exception("feeds == null");
            }

            FileDatasource fileDatasource = new FileDatasource(pathToFiles, this.httpContext);
            fileDatasource.RssFeeds = feeds;
            fileDatasource.Set();
        }
예제 #3
0
        public void HttpWebRequestTest()
        {
            // arrange
            Uri getUri = new Uri(this.DashboardConfiguration.DefaultUri);
            DashboardHttp http = new DashboardHttp(getUri);

            // act
            HttpWebRequest target = http.HttpWebRequest;

            // assert
            Assert.AreEqual(getUri, target.RequestUri);
            Assert.AreEqual("GET", target.Method);
            Assert.AreEqual("text/html", target.ContentType);
        }
예제 #4
0
        public void SaveResponseContentToFileTest()
        {
            // arrange

            // this number will be wrong if the file used is different,
            // ie, there are more, less, or different Rss feeds
            // at Windows Azure
            int fileLength = 14;

            Uri getUri = new Uri(this.DashboardConfiguration.DefaultUri);
            DashboardHttp target = new DashboardHttp(getUri);
            target.responseContent = "this is a test";

            string filename = DateTime.Now.Ticks + ".html";

            // act
            filename = target.SaveResponseContentToFile(filename);

            // assert
            Assert.IsFalse(string.IsNullOrEmpty(filename));

            FileInfo info = new FileInfo(filename);

            Assert.IsTrue(info.Exists);
            Assert.AreEqual(info.Length, fileLength);

            // cleanup
            File.Delete(filename);
        }
예제 #5
0
        public void RequestGETTest()
        {
            // arrange
            HttpContextBase context = null;

            FeedConfiguration dashboardConfiguration = new FeedConfiguration(context);
            Uri getUri = new Uri(@"http://www.microsoft.com");
            DashboardHttp target = new DashboardHttp(getUri);
            string actual = string.Empty;

            // act
            actual = target.GetRequest();

            // assert
            Assert.IsNotNull(actual);
        }