Exemplo n.º 1
0
        public void FindAssemblyByNameWithUnknownName()
        {
            LoaderFactory.Type = typeof(LoaderMock);
            IRecipe r = RecipeFactory.NewRecipe(string.Empty);

            r.AddAssembly(_csUnitTestExePath);
            var ta = r["fluffy duck"];

            Assert.Null(ta);
        }
Exemplo n.º 2
0
        private int Execute(string[] args)
        {
            var result = 0;

            try {
                var clh = new CmdLineHandler();
                SetUpCommandLineOptions(clh);
                clh.Evaluate(args);

                if (!clh.IsValid())
                {
                    PrintUsage();
                    result = 1;
                }
                else if (HelpNeeded(clh))
                {
                    PrintUsage();
                    result = 0;
                }
                else
                {
                    IRecipe recipe = null;
                    if (clh.HasOption("recipe"))
                    {
                        if (clh.HasOption("assembly"))
                        {
                            Console.WriteLine("Option 'recipe' present, ignoring option 'assembly'.");
                        }
                        recipe = RecipeFactory.Load(clh.GetOptionValueFor("recipe"));
                        if (recipe == null)
                        {
                            Console.WriteLine(String.Format(
                                                  "Couldn't read recipe at location '{0}'.",
                                                  clh.GetOptionValueFor("recipe")));
                            result = 1;
                        }
                    }
                    else if (clh.HasOption("assembly"))
                    {
                        var filePathName = clh.GetOptionValueFor("assembly");
                        if (File.Exists(filePathName))
                        {
                            recipe = RecipeFactory.NewRecipe(string.Empty);
                            recipe.AddAssembly(filePathName);
                        }
                        else
                        {
                            Console.WriteLine("Error: Couldn't read assembly at location '{0}'.", filePathName);
                            PrintUsage();
                            result = 1;
                        }
                    }
                    if (recipe != null &&
                        result == 0)
                    {
                        result = ExecuteValidCommandLine(clh, recipe);
                    }
                }
            }
            catch (Exception ex) {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                Console.WriteLine("Internal error: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
                result = 1;
            }
            Console.WriteLine("Done.");
            return(result);
        }