Ejemplo n.º 1
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.º 2
0
        public UsingCommandRepository()
        {
            MockedWriter = new();

            MockedTwitchClientManager = new();

            MockedUserCommandValidator = new();

            MockedCommandConfigurationStrategy = new();

            MockedTwitchClientManager.SetupAllProperties();

            MockedTwitchClient = MockedTwitchClientManager.SetupClient();

            MockedSetting1     = new();
            MockedSetting2     = new();
            MockedSetting3     = new();
            MockedCommand      = new();
            MockedUserCommand1 = new();
            MockedUserCommand2 = new();

            MockedSetting1.SetupAllProperties();
            MockedSetting2.SetupAllProperties();
            MockedSetting3.SetupAllProperties();
            MockedCommand.SetupAllProperties();
            MockedUserCommand1.SetupAllProperties();
            MockedUserCommand2.SetupAllProperties();

            MockedSetting1.Setup(x => x.Name).Returns(Name.From("s1"));
            MockedSetting2.Setup(x => x.Name).Returns(Name.From("s2"));
            MockedSetting3.Setup(x => x.Name).Returns(Name.From("s3"));
            MockedCommand.Setup(x => x.Name).Returns(Name.From("c"));
            MockedUserCommand1.Setup(x => x.Name).Returns(Name.From("uc1"));
            MockedUserCommand2.Setup(x => x.Name).Returns(Name.From("uc2"));

            MockedSetting1.Setup(x => x.Status).Returns("1");
            MockedSetting2.Setup(x => x.Status).Returns("2");
            MockedSetting3.Setup(x => x.Status).Returns("3");

            Sut = new CommandRepository(
                MockedWriter.Object,
                MockedTwitchClientManager.Object,
                MockedUserCommandValidator.Object,
                MockedCommandConfigurationStrategy.Object);
        }
Ejemplo n.º 3
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());
        }