public void ParseUrlsFromFile_ValidFilePathWith4Urls_ShouldMatch1stUrl()
        {
            // arrange
            IEnumerable<string> result;
            string sitemapsPath = @"C:\sitemaps.xml";
            using (var sitemapsFile = new MemoryStream())
            {
                WriteValidSitemapsStreamWith4Urls(sitemapsFile);

                var httpClient = new Mock<IHttpClient>();
                var streamFactory = new Mock<IStreamFactory>();
                streamFactory.Setup(x => x.GetFileStream(sitemapsPath, FileMode.Open, FileAccess.Read)).Returns(sitemapsFile);
                SitemapsParser target = new SitemapsParser(httpClient.Object, streamFactory.Object);

                // act
                result = target.ParseUrlsFromFile(sitemapsPath);
            }

            // assert
            var actual = result.ElementAt(1);
            var expected = "http://www.google.com/test.aspx";

            Assert.AreEqual(expected, actual);
        }
        public void ParseUrlsFromFile_ValidStreamWith4Urls_ShouldReturn4Urls()
        {
            // arrange
            var httpClient = new Mock<IHttpClient>();
            var streamFactory = new Mock<IStreamFactory>();
            SitemapsParser target = new SitemapsParser(httpClient.Object, streamFactory.Object);
            IEnumerable<string> result;

            using (Stream file = new MemoryStream())
            {
                WriteValidSitemapsStreamWith4Urls(file);

                // act
                result = target.ParseUrlsFromFile(file);
            }

            // assert
            var actual = result.Count();
            var expected = 4;

            Assert.AreEqual(expected, actual);
        }
        public void ParseUrlsFromFile_ValidUrlWith4Urls_ShouldMatch2ndUrl()
        {
            // arrange
            IEnumerable<string> result;
            string sitemapsUrl = "http://www.mydomain.com/sitemaps.xml";
            using (var sitemapsFile = new MemoryStream())
            {
                WriteValidSitemapsStreamWith4Urls(sitemapsFile);

                var httpClient = new Mock<IHttpClient>();
                httpClient.Setup(x => x.GetResponseStream(sitemapsUrl)).Returns(sitemapsFile);
                var streamFactory = new Mock<IStreamFactory>();
                SitemapsParser target = new SitemapsParser(httpClient.Object, streamFactory.Object);

                // act
                result = target.ParseUrlsFromFile(sitemapsUrl);
            }

            // assert
            var actual = result.ElementAt(1);
            var expected = "http://www.google.com/test.aspx";

            Assert.AreEqual(expected, actual);
        }
        public void ParseUrlsFromFile_ValidStreamWith4Urls_ShouldMatch2ndUrl()
        {
            // arrange
            var httpClient = new Mock<IHttpClient>();
            var streamFactory = new Mock<IStreamFactory>();
            SitemapsParser target = new SitemapsParser(httpClient.Object, streamFactory.Object);
            IEnumerable<string> result;

            using (Stream file = new MemoryStream())
            {
                WriteValidSitemapsStreamWith4Urls(file);

                // act
                result = target.ParseUrlsFromFile(file);
            }

            // assert
            var actual = result.ElementAt(1);
            var expected = "http://www.google.com/test.aspx";

            Assert.AreEqual(expected, actual);
        }