Inheritance: ICommandFactory
Example #1
0
 public void TestGetCommandInstanceSuccessForExistingTypeOfCommandInterface()
 {
     var assemblyQualifiedName = typeof(TestCommand).AssemblyQualifiedName;
     var cmdInstance = new CommandFactory().CreateCommand(assemblyQualifiedName);
     Assert.IsNotNull(cmdInstance);
     Assert.IsInstanceOfType(cmdInstance, typeof(ICommand));
 }
Example #2
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}");
            }
        }
Example #3
0
 public void TestInstanceCreatedSuccess()
 {
     var sut = new CommandFactory();
     Assert.IsNotNull(sut);
     Assert.IsInstanceOfType(sut,typeof(ICommandFactory));
 }