public void RecipeCurrentIsUsefulForInvalidRecipePathName() { var eventHandler = new MyEventHandler2(); RecipeFactory.Loaded += eventHandler.OnRecipeLoaded; RecipeFactory.LoadFailed += eventHandler.OnRecipeLoadFailed; Assert.NotNull(RecipeFactory.Current); RecipeFactory.Load("invalid.recipe"); Assert.NotNull(RecipeFactory.Current); Assert.Equals("OnRecipeLoadFailed", eventHandler.Events); }
public void FiresClosingLoadedEventsWithLoad() { XmlDocumentFactory.Type = typeof(XmlDocumentMock); XmlDocumentMock.PathName = _absoluteRecipeFileName; XmlDocumentMock.RawContent = "<recipe></recipe>"; var eventHandler = new MyEventHandler2(); RecipeFactory.Loaded += eventHandler.OnRecipeLoaded; RecipeFactory.Closing += eventHandler.OnRecipeClosing; RecipeFactory.Load(_absoluteRecipeFileName); Assert.Equals("OnRecipeClosingOnRecipeLoaded", eventHandler.Events); }
public void RecipeLoadedEventFired() { XmlDocumentFactory.Type = typeof(XmlDocumentMock); XmlDocumentMock.PathName = "test.recipe"; XmlDocumentMock.RawContent = "<recipe></recipe>"; LoaderFactory.Type = typeof(LoaderMock); var handler = new MyEventHandler(); RecipeFactory.Loaded += handler.OnRecipeLoaded; RecipeFactory.Load("test.recipe"); Assert.True(handler.Loaded); }
public void SaveRetrieve() { XmlDocumentFactory.Type = typeof(XmlDocumentMock); LoaderFactory.Type = typeof(LoaderMock); var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; var r = RecipeFactory.NewRecipe(string.Empty); r.AddAssembly(_csUnitTestExePath); r.Save(path + "\\SaveRetrieve.recipe"); var retrieved = RecipeFactory.Load(path + "\\SaveRetrieve.recipe"); Assert.Equals(1, retrieved.AssemblyCount); }
protected override void Execute(object sender, EventArgs args) { if (CommandTarget.AskSaveModifiedRecipe()) { var dlg = new OpenFileDialog { Filter = Constants.RECIPE_FILE_FILTER, Title = "Open Recipe" }; if (DialogResult.OK == dlg.ShowDialog(FindMainWindow())) { CommandTarget.Status = "Loading " + dlg.FileName + "..."; CommandTarget.Cursor = Cursors.WaitCursor; RecipeFactory.Load(dlg.FileName); CommandTarget.Cursor = Cursors.Default; CommandTarget.Status = "Ready"; } } }
/// <summary> /// Called, when an assembly has been chosen from the recent assemblies /// list to be loaded. /// </summary> /// <param name="assembly">Path and name of the assembly to be loaded.</param> static public void LoadFile(String assembly) { Cursor toBeRestored = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { if (assembly.ToUpper().EndsWith(".RECIPE")) { RecipeFactory.Load(assembly); } else { RecipeFactory.Current.AddAssembly(assembly); } } finally { Cursor.Current = toBeRestored; } }
private void MainForm_Load(object sender, EventArgs e) { var config = new ConfigCurrentUser(); Location = config.MainFormLocation; Size = config.MainFormSize; Command.CreateCommands(this, _csUnitControl); Command.FillToolStrip(_toolStrip); if (_clh.HasOption("recipe")) { if (Utils.FileExists(_clh.GetOptionValueFor("recipe"), true)) { RecipeFactory.Load(_clh.GetOptionValueFor("recipe")); } } else if (_clh.HasOption("assembly")) { if (Utils.FileExists(_clh.GetOptionValueFor("assembly"), true)) { var assemblyPathName = _clh.GetOptionValueFor("assembly"); if (!Path.IsPathRooted(assemblyPathName)) { assemblyPathName = Path.Combine(Environment.CurrentDirectory, assemblyPathName); } RecipeFactory.Current.AddAssembly(assemblyPathName); } } else { switch (config.StartupLoadItem) { case "Recipe": if (config.RecentRecipies.Count > 0 && Utils.FileExists(config.RecentRecipies[0], true)) { RecipeFactory.Load(config.RecentRecipies[0]); } break; case "Assembly": if (config.RecentAssemblies.Count > 0 && Utils.FileExists(config.RecentAssemblies[0], true)) { RecipeFactory.Current.AddAssembly(config.RecentAssemblies[0]); } break; } } // Setup the xml handler if (_clh.HasOption("xml")) { _xmlWriter = new DefaultXmlWriter(RecipeFactory.Current, _clh.GetOptionValueFor("xml")); } // Automatically start the recipe if (_clh.HasOption("autorun")) { if (RecipeFactory.Current != null) { var testRun = new TestRun(new AllTestsCriterion()); RecipeFactory.Current.RunTests(testRun); } } }
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); }