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()); }
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()); }
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()); }
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()); }
public void Disable() { Sut.Execute(Array.Empty <String>()); MockedWriter.Verify(x => x.WriteLine(It.IsAny <String>()), Times.Never()); Assert.False(Sut.IsEnabled); }
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()); }
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}\"")); }
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()); }
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")); }
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()); }
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()); }
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()); }
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()); }
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()); }
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);
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); }