Ejemplo n.º 1
0
        public void ShouldOutputBlockNotSuppliedMessage(String height)
        {
            Sut.Execute(new String[] { height });

            MockedWriter.Verify(x => x.WriteLine($"Pyramid block not supplied."));
            MockedTwitchClientManager.Verify(x => x.SpoolMessage(PrimaryChannelName, It.IsAny <String>(), It.IsAny <Priority>()), Times.Never());
        }
Ejemplo n.º 2
0
        public void ShouldOutputInvalidHeightMessage(String height)
        {
            Sut.Execute(new String[] { height });

            MockedWriter.Verify(x => x.WriteLine($"Pyramid height of \"{height}\" must be an integer"));
            MockedTwitchClientManager.Verify(x => x.SpoolMessage(PrimaryChannelName, It.IsAny <String>(), It.IsAny <Priority>()), Times.Never());
        }
Ejemplo n.º 3
0
        public void ShouldDisableAllSettingsWithNoArguments()
        {
            Sut.Execute(Array.Empty <String>());

            MockedCommandRepository.Verify(x => x.DisableAllSettings(), Times.Once());

            MockedWriter.Verify(x => x.WriteLine("Disabled all settings."), Times.Once());
        }
Ejemplo n.º 4
0
        public void ShouldDisableAllSettings(params String[] arguments)
        {
            Sut.Execute(arguments);

            MockedCommandRepository.Verify(x => x.DisableAllSettings(), Times.Once());

            MockedWriter.Verify(x => x.WriteLine("Disabled all settings."), Times.Once());
        }
Ejemplo n.º 5
0
        public void Disable()
        {
            Sut.Execute(Array.Empty <String>());

            MockedWriter.Verify(x => x.WriteLine(It.IsAny <String>()), Times.Never());

            Assert.False(Sut.IsEnabled);
        }
Ejemplo n.º 6
0
        public void ShouldSetGreeting(params String[] arguments)
        {
            Sut.Execute(arguments);

            String greeting = String.Join(" ", arguments);

            MockedWriter.Verify(x => x.WriteLine($"Greeting message is \"{greeting}\"."), Times.Once());
        }
Ejemplo n.º 7
0
        public void ShouldOutputProperties(params String[] arguments)
        {
            String userToCopy = arguments[0];
            String mode       = arguments[1];
            String prefix     = arguments[2];

            Sut.Execute(arguments);

            MockedWriter.Verify(x => x.WriteLine($"Copying user \"{userToCopy}\" Mode: \"{mode}\" Prefix: \"{prefix}\""));
        }
Ejemplo n.º 8
0
        public void ShouldOutputCommandNotFoundMessage(params String[] arguments)
        {
            String        invalidCommandName   = Guid.NewGuid().ToString();
            String        propertyName         = arguments[0];
            List <String> commandWithArguments = new() { invalidCommandName };

            commandWithArguments.AddRange(arguments);

            Sut.Execute(Name.From("set"), commandWithArguments);

            MockedWriter.Verify(x => x.WriteLine($"Command \"{invalidCommandName}\" not found to set."), Times.Once());
        }
Ejemplo n.º 9
0
        public void ShouldDisable()
        {
            Assert.Raises <OnSettingStateChangeArgs>(
                x => Sut.OnSettingStateChange += x,
                x => Sut.OnSettingStateChange -= x,
                () =>
            {
                Sut.Execute(Array.Empty <String>());
            });

            MockedWriter.Verify(x => x.WriteLine("Copy disabled"));
        }
Ejemplo n.º 10
0
        public void ShouldOutputPropertySetMessage(params String[] arguments)
        {
            MockedSetting1
            .Setup(x => x.Set(It.IsAny <String>(), It.IsAny <IEnumerable <String> >()))
            .Returns(true);

            var    validCommandName                   = MockedSetting1.Object.Name;
            String propertyName                       = arguments[0];
            IEnumerable <String> propertyValue        = arguments.Skip(1);
            List <String>        commandWithArguments = new() { validCommandName.Value };

            commandWithArguments.AddRange(arguments);

            Sut.Execute(Name.From("set"), commandWithArguments);

            MockedWriter.Verify(x => x.WriteLine($"Command \"{validCommandName}\" property \"{propertyName}\" set to \"{String.Join(" ", propertyValue)}\"."), Times.Once());
        }
Ejemplo n.º 11
0
        public void ShouldLogMessageData()
        {
            DateTime expectedDateTime    = DateTime.Now;
            String   expectedBotUserName = Guid.NewGuid().ToString();
            String   expectedData        = Guid.NewGuid().ToString();

            var args = new OnLogArgs()
            {
                DateTime    = expectedDateTime,
                BotUsername = expectedBotUserName,
                Data        = expectedData
            };

            Sut.TwitchClient_OnLog(null, args);

            MockedWriter.Verify(x => x.WriteLine($"{expectedDateTime}: {expectedBotUserName} - {expectedData}"), Times.Once());
        }
Ejemplo n.º 12
0
        public void ShouldDoNothing()
        {
            MockedStopSettingStrategy
            .Setup(x => x.ShouldStop(It.IsAny <ChatMessage>()))
            .Returns(false);

            Sut.Client_OnMessageReceived(null, new OnMessageReceivedArgs()
            {
                ChatMessage = ChatMessage
            });

            MockedStopSettingStrategy.Verify(x => x.ShouldStop(ChatMessage), Times.Once());

            MockedCommandRepository.Verify(x => x.DisableAllSettings(), Times.Never());

            MockedWriter.Verify(x => x.WriteLine(It.IsAny <String>()), Times.Never());
        }
Ejemplo n.º 13
0
        public void ShouldDisableAllSettings()
        {
            MockedStopSettingStrategy
            .Setup(x => x.ShouldStop(It.IsAny <ChatMessage>()))
            .Returns(true);

            Sut.Client_OnMessageReceived(null, new OnMessageReceivedArgs()
            {
                ChatMessage = ChatMessage
            });

            MockedStopSettingStrategy.Verify(x => x.ShouldStop(ChatMessage), Times.Once());

            MockedCommandRepository.Verify(x => x.DisableAllSettings(), Times.Once());

            MockedWriter.Verify(x => x.WriteLine("! ! ! DISABLED ALL SETTINGS ! ! !"), Times.Once());
            MockedWriter.Verify(x => x.WriteLine($"Moderator {ExpectedDisplayName} said: \"{ExpectedMessage}\""), Times.Once());
        }
Ejemplo n.º 14
0
        public void ShouldOutputPropertyNotSetMessage(params String[] arguments)
        {
            MockedSetting1
            .Setup(x => x.Set(It.IsAny <String>(), It.IsAny <IEnumerable <String> >()))
            .Returns((String property, IEnumerable <String> args) =>
            {
                return(property == "valid" && "valid" == args.FirstOrDefault());
            });

            var           validCommandName     = MockedSetting1.Object.Name;
            String        propertyName         = arguments[0];
            List <String> commandWithArguments = new() { validCommandName.Value };

            commandWithArguments.AddRange(arguments);

            Sut.Execute(Name.From("set"), commandWithArguments);

            MockedWriter.Verify(x => x.WriteLine($"Command \"{validCommandName}\" property \"{propertyName}\" not set."), Times.Once());
        }
Ejemplo n.º 15
0
        public void ShouldDoNothing()
        {
            var chatMessage = ChatMessageBuilder
                              .Create()
                              .WithTwitchLibMessage(TwitchLibMessageBuilder
                                                    .Create()
                                                    .WithBotUserName(ExpectedBotUsername)
                                                    .WithUsername(String.Empty)
                                                    .Build())
                              .WithMessage(ExpectedMessage)
                              .Build();

            Sut.TwitchClient_OnMessageReceived(null, new OnMessageReceivedArgs {
                ChatMessage = chatMessage
            });

            MockedWriter.Verify(x => x.WriteLine(It.IsAny <String>()), Times.Never());
            Assert.True(Sut.WaitingForRepeatMessage);
            Assert.Equal(default, Sut.RepeatMessage);
Ejemplo n.º 16
0
        public void ShouldRecordRepeatMessage()
        {
            var chatMessage = ChatMessageBuilder
                              .Create()
                              .WithTwitchLibMessage(TwitchLibMessageBuilder
                                                    .Create()
                                                    .WithBotUserName(ExpectedBotUsername)
                                                    .WithUsername(ExpectedBotUsername)
                                                    .Build())
                              .WithMessage(ExpectedMessage)
                              .Build();

            Sut.TwitchClient_OnMessageReceived(null, new OnMessageReceivedArgs {
                ChatMessage = chatMessage
            });

            MockedWriter.Verify(x => x.WriteLine($"Received repeat message: \"{ExpectedMessage}\""), Times.Once());
            Assert.False(Sut.WaitingForRepeatMessage);
            Assert.Equal(ExpectedMessage, Sut.RepeatMessage);
        }