Exemplo n.º 1
0
        public void Extract_SingleMentionTag_Dot_Test()
        {
            #region Stubs
            var message = $".@mynickname Bla!{Environment.NewLine}Blo";
            #endregion

            #region Mocks
            var logger = new Mock <ILogger <StatusExtractor> >();
            #endregion

            var service = new StatusExtractor(_settings, logger.Object);
            var result  = service.Extract(message);

            #region Validations
            logger.VerifyAll();
            Assert.AreEqual(1, result.tags.Length);
            Assert.AreEqual("@[email protected]", result.tags.First().name);
            Assert.AreEqual("Mention", result.tags.First().type);
            Assert.AreEqual("https://domain.name/users/mynickname", result.tags.First().href);

            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains("Blo"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@mynickname"" class=""u-url mention"">@<span>mynickname</span></a></span>"));
            #endregion
        }
        public void Extract_ReturnSingleLines_Test()
        {
            #region Stubs
            var message = "Bla.\n@Mention blo. https://t.co/pgtrJi9600";
            #endregion

            var service = new StatusExtractor(_settings);
            var result  = service.Extract(message);

            #region Validations
            Assert.IsTrue(result.content.Contains("Bla."));
            Assert.IsTrue(result.content.Contains("<br/>"));
            #endregion
        }
        public void Extract_Parenthesis_Test()
        {
            #region Stubs
            var message = $"bla (@mynickname test)";
            //var message = $"tests@mynickname";
            #endregion

            var service = new StatusExtractor(_settings);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(1, result.tags.Length);
            Assert.IsTrue(result.content.Equals(@"bla ( <span class=""h-card""><a href=""https://domain.name/@mynickname"" class=""u-url mention"">@<span>mynickname</span></a></span> test)"));
            #endregion
        }
        public void Extract_FormatUrl_Exact_Test()
        {
            #region Stubs
            var message = $"Bla!{Environment.NewLine}https://www.eff.org/deeplinks/2020/07/pact";
            #endregion

            var service = new StatusExtractor(_settings);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(0, result.tags.Length);

            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://www.eff.org/deeplinks/2020/07/pact"" rel=""nofollow noopener noreferrer"" target=""_blank""><span class=""invisible"">https://www.</span><span class=""ellipsis"">eff.org/deeplinks/2020/07/pact</span><span class=""invisible""></span></a>"));
            #endregion
        }
Exemplo n.º 5
0
        public void Extract_SmallUrl_3_Test()
        {
            #region Stubs
            var message = @"🚀http://GOV.UK.";
            #endregion

            #region Mocks
            var logger = new Mock <ILogger <StatusExtractor> >();
            #endregion

            var service = new StatusExtractor(_settings, logger.Object);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(@"🚀<a href=""http://GOV.UK"" rel=""nofollow noopener noreferrer"" target=""_blank""><span class=""invisible"">http://</span><span class=""ellipsis"">GOV.UK</span><span class=""invisible""></span></a>.", result.content);
            #endregion
        }
Exemplo n.º 6
0
        public void Extract_UrlRegexChars_Test()
        {
            #region Stubs
            var message = @"🐣 juniors & tech(http://tech.guru maker)";
            #endregion

            #region Mocks
            var logger = new Mock <ILogger <StatusExtractor> >();
            #endregion

            var service = new StatusExtractor(_settings, logger.Object);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(@"🐣 juniors & tech(<a href=""http://tech.guru"" rel=""nofollow noopener noreferrer"" target=""_blank""><span class=""invisible"">http://</span><span class=""ellipsis"">tech.guru</span><span class=""invisible""></span></a> maker)", result.content);
            #endregion
        }
        public void Extract_Emoji_Test()
        {
            #region Stubs
            var message = $"😤@mynickname 😎😍🤗🤩😘";
            //var message = $"tests@mynickname";
            #endregion

            var service = new StatusExtractor(_settings);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(1, result.tags.Length);
            Assert.IsTrue(result.content.Contains(
                              @"😤 <span class=""h-card""><a href=""https://domain.name/@mynickname"" class=""u-url mention"">@<span>mynickname</span></a></span>"));

            Assert.IsTrue(result.content.Contains(@"😎 😍 🤗 🤩 😘"));
            #endregion
        }
        public void Extract_MultiMentionTag_Test()
        {
            #region Stubs
            var message = $"Bla!{Environment.NewLine}@mynickname⁠ @mynickname2 @mynickname3{Environment.NewLine}Test @dada Test";
            #endregion

            var service = new StatusExtractor(_settings);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(4, result.tags.Length);
            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@mynickname"" class=""u-url mention"">@<span>mynickname</span></a></span>"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@mynickname2"" class=""u-url mention"">@<span>mynickname2</span></a></span>"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@mynickname3"" class=""u-url mention"">@<span>mynickname3</span></a></span>"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@dada"" class=""u-url mention"">@<span>dada</span></a></span>"));
            #endregion
        }
        public void Extract_MultiHashTags_Test()
        {
            #region Stubs
            var message = $"Bla!{Environment.NewLine}#mytag #mytag2 #mytag3⁠{Environment.NewLine}Test #bal Test";
            #endregion

            var service = new StatusExtractor(_settings);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(4, result.tags.Length);
            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag"" class=""mention hashtag"" rel=""tag"">#<span>mytag</span></a>"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag2"" class=""mention hashtag"" rel=""tag"">#<span>mytag2</span></a>"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag3"" class=""mention hashtag"" rel=""tag"">#<span>mytag3</span></a>"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/bal"" class=""mention hashtag"" rel=""tag"">#<span>bal</span></a>"));
            #endregion
        }
        public void Extract_SingleHashTag_AtStart_Test()
        {
            #region Stubs
            var message = $"#mytag⁠ Bla!";
            #endregion

            var service = new StatusExtractor(_settings);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(1, result.tags.Length);
            Assert.AreEqual("#mytag", result.tags.First().name);
            Assert.AreEqual("Hashtag", result.tags.First().type);
            Assert.AreEqual("https://domain.name/tags/mytag", result.tags.First().href);

            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag"" class=""mention hashtag"" rel=""tag"">#<span>mytag</span></a>"));
            #endregion
        }
        public void Extract_SingleMentionTag_AtStart_Test()
        {
            #region Stubs
            var message = $"@mynickname Bla!";
            #endregion

            var service = new StatusExtractor(_settings);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(1, result.tags.Length);
            Assert.AreEqual("@[email protected]", result.tags.First().name);
            Assert.AreEqual("Mention", result.tags.First().type);
            Assert.AreEqual("https://domain.name/users/mynickname", result.tags.First().href);

            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@mynickname"" class=""u-url mention"">@<span>mynickname</span></a></span>"));
            #endregion
        }
        public void Extract_SingleHashTag_SpecialChar_Test()
        {
            #region Stubs
            var message = $"Bla!{Environment.NewLine}#COVIDー19⁠";
            #endregion

            var service = new StatusExtractor(_settings);
            var result  = service.Extract(message);

            #region Validations
            Assert.AreEqual(1, result.tags.Length);
            Assert.AreEqual("#COVIDー19", result.tags.First().name);
            Assert.AreEqual("Hashtag", result.tags.First().type);
            Assert.AreEqual("https://domain.name/tags/COVIDー19", result.tags.First().href);

            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/COVIDー19"" class=""mention hashtag"" rel=""tag"">#<span>COVIDー19</span></a>"));
            #endregion
        }
Exemplo n.º 13
0
        public void Extract_ReturnSingleLines_Test()
        {
            #region Stubs
            var message = "Bla.\n@Mention blo. https://t.co/pgtrJi9600";
            #endregion

            #region Mocks
            var logger = new Mock <ILogger <StatusExtractor> >();
            #endregion

            var service = new StatusExtractor(_settings, logger.Object);
            var result  = service.Extract(message);

            #region Validations
            logger.VerifyAll();
            Assert.IsTrue(result.content.Contains("Bla."));
            Assert.IsTrue(result.content.Contains("<br/>"));
            #endregion
        }
Exemplo n.º 14
0
        public void Extract_FormatUrl_Long_Test()
        {
            #region Stubs
            var message = $"Bla!{Environment.NewLine}https://www.eff.org/deeplinks/2020/07/pact-act-not-solution-problem-harmful-online-content";
            #endregion

            #region Mocks
            var logger = new Mock <ILogger <StatusExtractor> >();
            #endregion

            var service = new StatusExtractor(_settings, logger.Object);
            var result  = service.Extract(message);

            #region Validations
            logger.VerifyAll();
            Assert.AreEqual(0, result.tags.Length);

            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://www.eff.org/deeplinks/2020/07/pact-act-not-solution-problem-harmful-online-content"" rel=""nofollow noopener noreferrer"" target=""_blank""><span class=""invisible"">https://www.</span><span class=""ellipsis"">eff.org/deeplinks/2020/07/pact</span><span class=""invisible"">-act-not-solution-problem-harmful-online-content</span></a>"));
            #endregion
        }
Exemplo n.º 15
0
        public void Extract_FormatUrl_Test()
        {
            #region Stubs
            var message = $"Bla!{Environment.NewLine}https://t.co/L8BpyHgg25";
            #endregion

            #region Mocks
            var logger = new Mock <ILogger <StatusExtractor> >();
            #endregion

            var service = new StatusExtractor(_settings, logger.Object);
            var result  = service.Extract(message);

            #region Validations
            logger.VerifyAll();
            Assert.AreEqual(0, result.tags.Length);

            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://t.co/L8BpyHgg25"" rel=""nofollow noopener noreferrer"" target=""_blank""><span class=""invisible"">https://</span><span class=""ellipsis"">t.co/L8BpyHgg25</span><span class=""invisible""></span></a>"));
            #endregion
        }
Exemplo n.º 16
0
        public void Extract_MultiMentionTag_MultiOccurrence_Test()
        {
            #region Stubs
            var message = $"[RT @yamenbousrih]{Environment.NewLine}@KiwixOffline @photos_floues Bla. Cc @Pyb75 @photos_floues @KiwixOffline";
            #endregion

            #region Mocks
            var logger = new Mock <ILogger <StatusExtractor> >();
            #endregion

            var service = new StatusExtractor(_settings, logger.Object);
            var result  = service.Extract(message);

            #region Validations
            logger.VerifyAll();
            Assert.AreEqual(4, result.tags.Length);
            Assert.AreEqual("Mention", result.tags.First().type);

            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@photos_floues"" class=""u-url mention"">@<span>photos_floues</span></a></span>"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@KiwixOffline"" class=""u-url mention"">@<span>KiwixOffline</span></a></span> <span class=""h-card""><a href=""https://domain.name/@photos_floues"" class=""u-url mention"">@<span>photos_floues</span></a></span>"));
            Assert.IsTrue(result.content.Contains(@"Cc <span class=""h-card""><a href=""https://domain.name/@Pyb75"" class=""u-url mention"">@<span>Pyb75</span></a></span> <span class=""h-card""><a href=""https://domain.name/@photos_floues"" class=""u-url mention"">@<span>photos_floues</span></a></span> <span class=""h-card""><a href=""https://domain.name/@KiwixOffline"" class=""u-url mention"">@<span>KiwixOffline</span></a></span>"));
            #endregion
        }
Exemplo n.º 17
0
        public void Extract_SingleHashTag_Test()
        {
            #region Stubs
            var message = $"Bla!{Environment.NewLine}#mytag";
            #endregion

            #region Mocks
            var logger = new Mock <ILogger <StatusExtractor> >();
            #endregion

            var service = new StatusExtractor(_settings, logger.Object);
            var result  = service.Extract(message);

            #region Validations
            logger.VerifyAll();
            Assert.AreEqual(1, result.tags.Length);
            Assert.AreEqual("#mytag", result.tags.First().name);
            Assert.AreEqual("Hashtag", result.tags.First().type);
            Assert.AreEqual("https://domain.name/tags/mytag", result.tags.First().href);

            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag"" class=""mention hashtag"" rel=""tag"">#<span>mytag</span></a>"));
            #endregion
        }
Exemplo n.º 18
0
        public void Extract_HeterogeneousTag_Test()
        {
            #region Stubs
            var message = $"Bla!{Environment.NewLine}@mynickname⁠ #mytag2 @mynickname3{Environment.NewLine}Test @dada #dada Test";
            #endregion

            #region Mocks
            var logger = new Mock <ILogger <StatusExtractor> >();
            #endregion

            var service = new StatusExtractor(_settings, logger.Object);
            var result  = service.Extract(message);

            #region Validations
            logger.VerifyAll();
            Assert.AreEqual(5, result.tags.Length);
            Assert.IsTrue(result.content.Contains("Bla!"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@mynickname"" class=""u-url mention"">@<span>mynickname</span></a></span>"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/mytag2"" class=""mention hashtag"" rel=""tag"">#<span>mytag2</span></a>"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@mynickname3"" class=""u-url mention"">@<span>mynickname3</span></a></span>"));
            Assert.IsTrue(result.content.Contains(@"<span class=""h-card""><a href=""https://domain.name/@dada"" class=""u-url mention"">@<span>dada</span></a></span>"));
            Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/dada"" class=""mention hashtag"" rel=""tag"">#<span>dada</span></a>"));
            #endregion
        }