Beispiel #1
0
        public void MentionAtEndIsCorrectlyExtracted()
        {
            // Arrange
            const string text = "This is a @test";

            // Act
            var mentions = EntityParser.ExtractMentions(text);

            // Assert
            Assert.AreEqual(1, mentions.Count);

            var m = mentions.First();

            Assert.AreEqual(10, m.Start);
            Assert.AreEqual(15, m.End);
            Assert.AreEqual("test", m.ScreenName);
        }
Beispiel #2
0
        public void MentionInMiddleIsExtractedCorrectly()
        {
            // Arrange
            const string text = "Hello @World how are you?";

            // Act
            var mentions = EntityParser.ExtractMentions(text);

            // Assert
            Assert.AreEqual(1, mentions.Count);

            var m = mentions.First();

            Assert.AreEqual(6, m.Start);
            Assert.AreEqual(12, m.End);
            Assert.AreEqual("World", m.ScreenName);
        }
Beispiel #3
0
        public void MentionAtStartIsCorrectlyExtracted()
        {
            // Arrange
            const string text = "@username Hello";

            // Act
            var mentions = EntityParser.ExtractMentions(text);

            // Assert
            Assert.AreEqual(1, mentions.Count);

            var m = mentions.First();

            Assert.AreEqual(0, m.Start);
            Assert.AreEqual(9, m.End);
            Assert.AreEqual("username", m.ScreenName);
        }
Beispiel #4
0
        public ScheduleItem(SchedulerJob job, UserViewModel user, IScheduler scheduler, IConfig config, IViewServiceRepository viewServices)
            : base(config, viewServices)
        {
            Job          = job;
            User         = user;
            Scheduler    = scheduler;
            ViewServices = viewServices;

            Entities = new Entities
            {
                HashTagEntities     = EntityParser.ExtractHashtags(job.Text),
                MediaEntities       = new List <MediaEntity>(),
                SymbolEntities      = new List <SymbolEntity>(),
                UrlEntities         = new List <UrlEntity>(),
                UserMentionEntities = EntityParser.ExtractMentions(job.Text)
            };
        }
Beispiel #5
0
        public ScheduleItem(SchedulerJob job, UserViewModel user, IScheduler scheduler, IConfig config, IViewServiceRepository viewServices)
            : base(config, viewServices)
        {
            Job          = job;
            User         = user;
            Scheduler    = scheduler;
            ViewServices = viewServices;

            Entities = new Entities
            {
                HashTagEntities     = EntityParser.ExtractHashtags(job.Text),
                MediaEntities       = new List <MediaEntity>(),
                SymbolEntities      = new List <SymbolEntity>(),
                UrlEntities         = new List <UrlEntity>(),
                UserMentionEntities = EntityParser.ExtractMentions(job.Text)
            };

            BlockUserCommand  = new LogMessageCommand("Tried to block user from ScheduleItem", LogLevel.Warn);
            ReportSpamCommand = new LogMessageCommand("Tried to report user from ScheduleItem", LogLevel.Warn);
        }
Beispiel #6
0
        public void MultipleMentionsAreCorrectlyExtracted()
        {
            // Arrange
            const string text = "@user @test Hello";

            // Act
            var mentions = EntityParser.ExtractMentions(text);

            // Assert
            Assert.AreEqual(2, mentions.Count);

            var m = mentions.First();

            Assert.AreEqual(0, m.Start);
            Assert.AreEqual(5, m.End);
            Assert.AreEqual("user", m.ScreenName);

            m = mentions.Last();
            Assert.AreEqual(6, m.Start);
            Assert.AreEqual(11, m.End);
            Assert.AreEqual("test", m.ScreenName);
        }