Exemple #1
0
        public void EnsureEventIsRaisedWhenHelpCommandIsMapped()
        {
            var applicationArgs     = new CommandsWithName();
            var commandLineArgument = new CommandLineArgument {
                Name = "?"
            };
            var dictionary = new Dictionary <string, CommandLineArgument> {
                { "?", commandLineArgument }
            };

            var commandMapper = new CommandMapper <CommandsWithName>(Setup.EngineFactory().Done());

            commandMapper.MonitorEvents();

            var result = commandMapper.Map(dictionary, applicationArgs);

            result.Help.Should().NotBeNull();
            commandMapper.ShouldRaise(nameof(CommandMapper <CommandsWithName> .MappedCommandLineArgument))
            .WithArgs <MapperEventArgs>(args => args.Argument == commandLineArgument);
        }
Exemple #2
0
        public void EnsureEventIsRaisedWhenCommandIsMapped()
        {
            var applicationArgs     = new CommandsWithName();
            var commandLineArgument = new CommandLineArgument {
                Name = "name"
            };
            var property   = typeof(CommandsWithName).GetProperty(nameof(CommandsWithName.Execute));
            var dictionary = new Dictionary <string, CommandLineArgument> {
                { commandLineArgument.Name, commandLineArgument }
            };

            var commandMapper = new CommandMapper <CommandsWithName>(Setup.EngineFactory().Done());

            commandMapper.MonitorEvents();

            var result = commandMapper.Map(dictionary, applicationArgs);

            result.Execute.Should().NotBeNull();
            commandMapper.ShouldRaise(nameof(CommandMapper <CommandsWithName> .MappedCommandLineArgument))
            .WithArgs <MapperEventArgs>(args => args.Argument == commandLineArgument)
            .WithArgs <MapperEventArgs>(args => args.PropertyInfo == property);
        }