Exemplo n.º 1
0
        public void RegularUsageTest()
        {
            var commandTestClass = new ArgumentTestClass();
            var dictionary       = new Dictionary <string, CommandLineArgument>
            {
                { "SimpleArgument", new CommandLineArgument {
                      Value = "\"SimpleArgumentValue\""
                  } },
                { "TheName", new CommandLineArgument {
                      Value = "TheNameValue"
                  } },
                { "TrimmedArgument", new CommandLineArgument {
                      Value = "TrimmedArgumentValue"
                  } },
                { "RequiredArgument", new CommandLineArgument {
                      Value = "RequiredArgumentValue"
                  } }
            };
            var argumentMapper = Setup.ArgumentMapper().ForType <ArgumentTestClass>().Done();
            var result         = argumentMapper.Map(dictionary, commandTestClass);

            Assert.AreEqual(result.SimpleArgument, "\"SimpleArgumentValue\"");
            Assert.AreEqual(result.NamedArgument, "TheNameValue");
            Assert.AreEqual(result.TrimmedArgument, "TrimmedArgumentValue");
            Assert.AreEqual(result.RequiredArgument, "RequiredArgumentValue");
        }
Exemplo n.º 2
0
        public void NotUsedRequiredArgumentErrorTest()
        {
            var commandTestClass = new ArgumentTestClass();
            var dictionary       = new Dictionary <string, CommandLineArgument>();

            var argumentMapper = Setup.ArgumentMapper().ForType <ArgumentTestClass>().Done();

            argumentMapper.Invoking(x => x.Map(dictionary, commandTestClass)).ShouldThrow <MissingCommandLineArgumentException>();
        }
Exemplo n.º 3
0
        public void NamedArgumentAliasTest()
        {
            var commandTestClass = new ArgumentTestClass();
            var dictionary       = new Dictionary <string, CommandLineArgument>
            {
                { "AliasName1", new CommandLineArgument {
                      Value = "TheNameValue"
                  } },
                { "RequiredArgument", new CommandLineArgument {
                      Value = "RequiredArgumentValue"
                  } }
            };

            var argumentMapper = Setup.ArgumentMapper().ForType <ArgumentTestClass>().Done();
            var result         = argumentMapper.Map(dictionary, commandTestClass);

            Assert.AreEqual(result.NamedArgument, "TheNameValue");
        }