Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            try
            {
                XmlConfigurator.Configure();

                var cfg = new CommandLineConfiguration { CmdLineArgs = args };
                var commandInstance = new CommandFactory()
                    .CreateCommand(cfg.GetMandatoryConfigValue(CommandKey));

                (commandInstance as IConfigurable)?.Configure(cfg);

                Logger.Info($"Executing command {commandInstance.GetType().Name}...");

                commandInstance.Execute();

                Logger.Info($"Command {commandInstance.GetType().Name} executed.");
            }
            catch (Exception e)
            {
                Logger.Error($"Error executing application: {e.Message}");
                var innerException = e.InnerException;
                while (null != innerException)
                {
                    Logger.Error(innerException.Message);
                    innerException = innerException.InnerException;
                }
                Logger.Error($"Stack trace: {e.StackTrace}");
            }
        }
Exemplo n.º 2
0
 public void TestGetConfigurationSuccessWithValidConfiguration()
 {
     var cfgDict = new CommandLineConfiguration { CmdLineArgs = new[] { "Param1=value1", "Param2=value2" } }.GetConfiguration();
     Assert.IsNotNull(cfgDict);
     Assert.IsInstanceOfType(cfgDict, typeof(IDictionary<string,string>));
     Assert.AreEqual(2,cfgDict.Count);
     Assert.AreEqual("param1",cfgDict.First().Key);
     Assert.AreEqual("param2", cfgDict.Last().Key);
     Assert.AreEqual("value1", cfgDict.First().Value);
     Assert.AreEqual("value2", cfgDict.Last().Value);
 }