Beispiel #1
0
        public void Nuke_MessagesInAndOutOfRadius_TargetsOnlyInRadius()
        {
            var container   = NukeHelper.GetContainer(_messagesInAndOutOfRadius.CreatedAt, _messagesInAndOutOfRadius.NukeBlastRadius);
            var logic       = container.GetInstance <ModCommandLogic>();
            var factory     = container.GetInstance <ReceivedFactory>();
            var nukeFactory = container.GetInstance <IFactory <IReceived <Moderator, IMessage>, Nuke> >();

            var nukeResults = logic.Nuke(_messagesInAndOutOfRadius.Build(), nukeFactory.Create(factory.ModPublicReceivedMessage("!nuke10m message")));

            var nukedUsers = nukeResults.OfType <SendableMute>().Select(umb => umb.Target);

            _messagesInAndOutOfRadius.VerifyTargeted(nukedUsers);
        }
Beispiel #2
0
        public void Nuke_MessagesContainingAndSimilarToNukedWord_TargetsAppropriate()
        {
            var container   = NukeHelper.GetContainer(_messagesContainingAndSimilarToNukedWord.NextTimestamp(), _messagesContainingAndSimilarToNukedWord.NukeBlastRadius);
            var logic       = container.GetInstance <ModCommandLogic>();
            var factory     = container.GetInstance <ReceivedFactory>();
            var nukeFactory = container.GetInstance <IFactory <IReceived <Moderator, IMessage>, Nuke> >();

            var nukeResults = logic.Nuke(_messagesContainingAndSimilarToNukedWord.Build(), nukeFactory.Create(factory.ModPublicReceivedMessage("!nuke10m message")));

            var nukedUsers = nukeResults.OfType <SendableMute>().Select(umb => umb.Target);

            _messagesContainingAndSimilarToNukedWord.VerifyTargeted(nukedUsers);
        }
Beispiel #3
0
        public void Nuke_MessagesWithDifferentCasing_IsCaseInsensitive()
        {
            var container   = NukeHelper.GetContainer(_messagesWithDifferentCasing.NextTimestamp(), _messagesWithDifferentCasing.NukeBlastRadius);
            var logic       = container.GetInstance <ModCommandLogic>();
            var factory     = container.GetInstance <ReceivedFactory>();
            var nukeFactory = container.GetInstance <IFactory <IReceived <Moderator, IMessage>, Nuke> >();

            var nukeResults = logic.Nuke(_messagesWithDifferentCasing.Build(), nukeFactory.Create(factory.ModPublicReceivedMessage("!nuke10m message")));

            var nukedUsers = nukeResults.OfType <SendableMute>().Select(umb => umb.Target);

            _messagesWithDifferentCasing.VerifyTargeted(nukedUsers);
        }
Beispiel #4
0
        public void Aegis_MessagesInAndOutOfRadius_TargetsOnlyInRadius()
        {
            var container       = NukeHelper.GetContainer(_messagesInAndOutOfRadius.CreatedAt, _messagesInAndOutOfRadius.NukeBlastRadius);
            var logic           = container.GetInstance <ModCommandLogic>();
            var factory         = container.GetInstance <ReceivedFactory>();
            var nuke            = factory.ModPublicReceivedMessage("!nuke10m message");
            var contextWithNuke = _messagesInAndOutOfRadius.Build().Concat(nuke.Wrap()).ToList();

            var aegisResults = logic.Aegis(contextWithNuke);

            var aegisedUsers = aegisResults.OfType <SendablePardon>().Select(umb => umb.Target);

            _messagesInAndOutOfRadius.VerifyTargeted(aegisedUsers);
        }
Beispiel #5
0
        public void Aegis_MessagesWithDifferentCasing_IsCaseInsensitive()
        {
            var container       = NukeHelper.GetContainer(_messagesWithDifferentCasing.NextTimestamp(), _messagesWithDifferentCasing.NukeBlastRadius);
            var logic           = container.GetInstance <ModCommandLogic>();
            var factory         = container.GetInstance <ReceivedFactory>();
            var nuke            = factory.ModPublicReceivedMessage("!nuke10m message");
            var contextWithNuke = _messagesWithDifferentCasing.Build().Concat(nuke.Wrap()).ToList();

            var aegisResults = logic.Aegis(contextWithNuke);

            var aegisedUsers = aegisResults.OfType <SendablePardon>().Select(umb => umb.Target);

            _messagesWithDifferentCasing.VerifyTargeted(aegisedUsers);
        }
Beispiel #6
0
        public void Aegis_MessagesContainingAndSimilarToNuked_TargetsAppropriate()
        {
            var container       = NukeHelper.GetContainer(_messagesContainingAndSimilarToNukedWord.NextTimestamp(), _messagesContainingAndSimilarToNukedWord.NukeBlastRadius);
            var logic           = container.GetInstance <ModCommandLogic>();
            var factory         = container.GetInstance <ReceivedFactory>();
            var nuke            = factory.ModPublicReceivedMessage("!nuke10m message");
            var contextWithNuke = _messagesContainingAndSimilarToNukedWord.Build().Concat(nuke.Wrap()).ToList();

            var aegisResults = logic.Aegis(contextWithNuke);

            var aegisedUsers = aegisResults.OfType <SendablePardon>().Select(umb => umb.Target);

            _messagesContainingAndSimilarToNukedWord.VerifyTargeted(aegisedUsers);
        }
Beispiel #7
0
        public void OutOfRangeAegis()
        {
            var inserter = new ContextInserterBuilder()
                           .InsertAt(" 0:59:59.9999999  ").PublicMessage("message")
                           .InsertAt(" 1:00           ").TargetedMessage("message")
                           .InsertAt(" 1:05                ").ModMessage("!nuke MESSage")
                           .CreateAt(" 1:05")
                           .RadiusIs(" 0:05");
            var container = NukeHelper.GetContainer(inserter.CreatedAt, inserter.NukeBlastRadius);

            var aegisResults = container.GetInstance <ModCommandLogic>().Aegis(inserter.Build());

            var aegisedUsers = aegisResults.OfType <SendablePardon>().Select(umb => umb.Target);

            inserter.VerifyTargeted(aegisedUsers);
        }
Beispiel #8
0
        public void DoubleNukeRegexNukeAegis()
        {
            var appender = new ContextAppenderBuilder(TimeSpan.FromTicks(1))
                           .PublicMessage("innocent")
                           .TargetedMessage("xyz")
                           .TargetedMessage("abc")
                           .PublicMessage("herp")
                           .ModMessage("!nuke xyz")
                           .ModMessage("!nukeregex abc")
                           .PublicMessage("derp")
                           .RadiusIs("0:05");
            var container = NukeHelper.GetContainer(appender.NextTimestamp(), appender.NukeBlastRadius);

            var aegisResults = container.GetInstance <ModCommandLogic>().Aegis(appender.Build());

            var aegisedUsers = aegisResults.OfType <SendablePardon>().Select(umb => umb.Target);

            appender.VerifyTargeted(aegisedUsers);
        }
Beispiel #9
0
        public void Aegis_SameUserSameTwoMessages_OneMute()
        {
            var nick             = "MyNick";
            var nukedText        = "nuked words";
            var nukeTimestamp    = new DateTime(2000, 1, 1, 0, 10, 0);
            var container        = NukeHelper.GetContainer(nukeTimestamp, TimeSpan.FromMinutes(10));
            var logic            = container.GetInstance <ModCommandLogic>();
            var receivedFactory  = container.GetInstance <ReceivedFactory>();
            var nukeableMessage1 = receivedFactory.PublicReceivedMessage(nick, nukedText);
            var nukeableMessage2 = receivedFactory.PublicReceivedMessage(nick, nukedText);
            var nuke             = receivedFactory.ModPublicReceivedMessage($"!nuke10m {nukedText}");
            var context          = new List <IReceived <IUser, ITransmittable> > {
                nukeableMessage1, nukeableMessage2, nuke
            };

            var pardons = logic.Aegis(context);

            Assert.AreEqual(1, pardons.Count);
        }