Exemplo n.º 1
0
        public void Lifewire_TechTodayFactory()
        {
            // Arrange
            EmailReader.Infrastructure.AutofacConfig.Configuration();
            var container = EmailReader.Infrastructure.AutofacConfig.Container;

            string[] files = Assembly.GetExecutingAssembly().GetManifestResourceNames().Where(
                dir => dir.Contains("TechToday")).ToArray();

            Type    targetType = new TechTodayParser().GetType();
            IParser parser     = null;

            foreach (var file in files)
            {
                var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(file);

                // Act
                using (StreamReader sr = new StreamReader(stream))
                {
                    EmailDto emailDto = new EmailDto
                    {
                        Subject   = sr.ReadLine(),
                        From      = sr.ReadLine(),
                        MessageId = Convert.ToInt32(sr.ReadLine()),
                        Body      = sr.ReadToEnd()
                    };

                    parser = new ParserFactory().GetParser(emailDto, container);
                }

                // Assert
                Assert.IsInstanceOfType(parser, targetType);
            }
        }
Exemplo n.º 2
0
        public void TechToday_152_9AndroidAppsToMake()
        {
            // Arrange
            string fileName = "152_9 Android Apps to Make Your Phone Run Faster.html";

            ArticleDto articleDtoTemplate = new ArticleDto
            {
                Title = "9 Android Apps to Make Your Phone Run Faster",
                Link  = "http://link.lifewire.com/click/13650094.92107/aHR0cHM6Ly93d3cubGlmZXdpcmUuY29tL2Jlc3QtYW5kcm9pZC1ib29zdGVyLWFwcHMtNDE2NTUxMz91dG1fY2FtcGFpZ249Y29tcHV0ZXJzbCZ1dG1fbWVkaXVtPWVtYWlsJnV0bV9zb3VyY2U9Y25fbmwmdXRtX2NvbnRlbnQ9MTM2NTAwOTQmdXRtX3Rlcm09/5b2bb4ac639ec82cd4094eb9Bdefaf342"
            };

            EmailDto emailDto = this.GetDtoFromTestFiles(fileName);

            // Act
            IParser    parser     = new TechTodayParser();
            ArticleDto articleDto = parser.Parse(emailDto.Subject, emailDto.Body);

            // Assert
            Assert.AreEqual(articleDtoTemplate.Title, articleDto.Title);
            Assert.AreEqual(articleDtoTemplate.Link, articleDto.Link);
        }
Exemplo n.º 3
0
        public void TechToday_158_ProtectYourPrivacy()
        {
            // Arrange
            string fileName = "158_Protect Your Privacy by Locking Apps on Your iPhone.html";

            ArticleDto articleDtoTemplate = new ArticleDto
            {
                Title = "Protect Your Privacy by Locking Apps on Your iPhone",
                Link  = "http://link.lifewire.com/click/13650063.92139/aHR0cHM6Ly93d3cubGlmZXdpcmUuY29tL2xvY2stYXBwcy1vbi1pcGhvbmUtNDE2NDg2ND91dG1fY2FtcGFpZ249Y29tcHV0ZXJzbCZ1dG1fbWVkaXVtPWVtYWlsJnV0bV9zb3VyY2U9Y25fbmwmdXRtX2NvbnRlbnQ9MTM2NTAwNjMmdXRtX3Rlcm09/5b2bb4ac639ec82cd4094eb9B3e48beec"
            };

            EmailDto emailDto = this.GetDtoFromTestFiles(fileName);

            // Act
            IParser    parser     = new TechTodayParser();
            ArticleDto articleDto = parser.Parse(emailDto.Subject, emailDto.Body);

            // Assert
            Assert.AreEqual(articleDtoTemplate.Title, articleDto.Title);
            Assert.AreEqual(articleDtoTemplate.Link, articleDto.Link);
        }
Exemplo n.º 4
0
        public void TechToday_169_BoostYourMusic()
        {
            // Arrange
            string fileName = "169_Boost Your Music with Tech Tips.html";

            ArticleDto articleDtoTemplate = new ArticleDto
            {
                Title = "Boost Your Music with Tech Tips",
                Link  = "http://link.lifewire.com/click/13639644.159979/aHR0cHM6Ly93d3cubGlmZXdpcmUuY29tL3Nwb25zb3JlZC9tdXNpY2FsdHJhdmVsc3Rocm91Z2h0ZWNoP3V0bV9jYW1wYWlnbj1jb21wdXRlcnNsJnV0bV9tZWRpdW09ZW1haWwmdXRtX3NvdXJjZT1jbl9ubCZ1dG1fY29udGVudD0xMzYzOTY0NCZ1dG1fdGVybT0/5b2bb4ac639ec82cd4094eb9B968f1aad"
            };

            EmailDto emailDto = this.GetDtoFromTestFiles(fileName);

            // Act
            IParser    parser     = new TechTodayParser();
            ArticleDto articleDto = parser.Parse(emailDto.Subject, emailDto.Body);

            // Assert
            Assert.AreEqual(articleDtoTemplate.Title, articleDto.Title);
            Assert.AreEqual(articleDtoTemplate.Link, articleDto.Link);
        }
Exemplo n.º 5
0
        public void TechToday_147_10TypesOfInternetTrolls()
        {
            // Arrange
            string fileName = "147_10 Types of Internet Trolls You’ll Meet Online.html";

            ArticleDto articleDtoTemplate = new ArticleDto
            {
                Title = "10 Types of Internet Trolls You’ll Meet Online",
                Link  = "http://link.lifewire.com/click/13674363.91819/aHR0cHM6Ly93d3cubGlmZXdpcmUuY29tL3R5cGVzLW9mLWludGVybmV0LXRyb2xscy0zNDg1ODk0P3V0bV9jYW1wYWlnbj1jb21wdXRlcnNsJnV0bV9tZWRpdW09ZW1haWwmdXRtX3NvdXJjZT1jbl9ubCZ1dG1fY29udGVudD0xMzY3NDM2MyZ1dG1fdGVybT0/5b2bb4ac639ec82cd4094eb9B51b81171"
            };

            EmailDto emailDto = this.GetDtoFromTestFiles(fileName);

            // Act
            IParser    parser     = new TechTodayParser();
            ArticleDto articleDto = parser.Parse(emailDto.Subject, emailDto.Body);

            // Assert
            Assert.AreEqual(articleDtoTemplate.Title, articleDto.Title);
            Assert.AreEqual(articleDtoTemplate.Link, articleDto.Link);
        }
Exemplo n.º 6
0
        public void TechToday_151_8PlugsToMakeYourHome()
        {
            // Arrange
            string fileName = "151_8 Plugs to Make Your Home a Little Smarter.html";

            ArticleDto articleDtoTemplate = new ArticleDto
            {
                Title = "8 Plugs to Make Your Home a Little Smarter",
                Link  = "http://link.lifewire.com/click/13650146.91947/aHR0cHM6Ly93d3cubGlmZXdpcmUuY29tL2Jlc3Qtc21hcnQtcGx1Z3MtNDE2MzAwMT91dG1fY2FtcGFpZ249Y29tcHV0ZXJzbCZ1dG1fbWVkaXVtPWVtYWlsJnV0bV9zb3VyY2U9Y25fbmwmdXRtX2NvbnRlbnQ9MTM2NTAxNDYmdXRtX3Rlcm09/5b2bb4ac639ec82cd4094eb9Ba3d4474d"
            };

            EmailDto emailDto = this.GetDtoFromTestFiles(fileName);

            // Act
            IParser    parser     = new TechTodayParser();
            ArticleDto articleDto = parser.Parse(emailDto.Subject, emailDto.Body);

            // Assert
            Assert.AreEqual(articleDtoTemplate.Title, articleDto.Title);
            Assert.AreEqual(articleDtoTemplate.Link, articleDto.Link);
        }