Пример #1
0
        public void RegisterCommandT_ShouldReadFlagLazyEnvironmentVariable_IfSetAfterInitialization()
        {
            var testEnvironment = new TestEnvironment();

            LazyEnvironmentArgumentsType commandArgs = null;

            Cli
            .Configure(c => c
                       .SetDialect(Dialect.Gnu)
                       .SetEnvironment(testEnvironment)
                       )
            .Root <LazyEnvironmentArgumentsType>(c => c
                                                 .SetExecute((args, output) => { commandArgs = args; })
                                                 )
            .Run(new string[0]);

            testEnvironment
            .SetEnvironmentVariable("NFLAG_TEST_FLAG_ENV", "false");

            Assert.False(commandArgs.Flag.Value);
        }
Пример #2
0
        public void RegisterCommandT_ShouldReadLazyParameterEnvironmentVariable_IfSetAfterInitialization()
        {
            var testEnvironment = new TestEnvironment();

            LazyEnvironmentArgumentsType commandArgs = null;

            Cli
            .Configure(c => c
                       .SetDialect(Dialect.Gnu)
                       .SetEnvironment(testEnvironment)
                       )
            .Root <LazyEnvironmentArgumentsType>(c => c
                                                 .SetExecute((args, output) => { commandArgs = args; })
                                                 )
            .Run(new string[0]);

            testEnvironment
            .SetEnvironmentVariable("NFLAG_TEST_PARAM_ENV", "env_p");

            Assert.Equal("env_p", commandArgs.Parameter.Value);
        }