Esempio n. 1
0
        public void LoadProject(string fileName, bool silent)
        {
            if (!File.Exists(fileName))
            {
                if (!silent)
                {
                    MessageBox.Show("Could not find file");
                }
                return;
            }

            try
            {
                this.MessageOnStatusBar("Loading {0}", fileName);
                MbUnitProject project = MbUnitProject.Load(fileName);
                // removing assemblies
                this.RemoveAssemblies();
                // adding assemblies
                foreach (string testFilePath in project.Assemblies)
                {
                    this.AddAssembly(testFilePath);
                }
                // setting state
                this.state.Load(project.TreeState);
            }
            catch (Exception ex)
            {
                if (ex is System.Threading.ThreadAbortException)
                {
                    return;
                }

                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 2
0
        public void SaveProject(string fileName)
        {
            MbUnitProject project = new MbUnitProject();

            foreach (TestDomain domain in this.TestDomains)
            {
                project.Assemblies.Add(domain.TestFilePath);
            }
            this.state.Save();
            project.TreeState = this.state.GetTreeViewState();

            project.Save(fileName);
        }
Esempio n. 3
0
        public void SaveAndLoadTest()
        {
            // Save test project
            proj = new MbUnitProject();
            proj.Assemblies.Add("string1");
            proj.Assemblies.Add("string2");
            proj.Assemblies.Add("string3");
            proj.Save(filename);

            // Re-load project
            proj = MbUnitProject.Load(filename);
            Assert.AreEqual(3, proj.Assemblies.Count);
            CollectionAssert.Contains(proj.Assemblies, "string1");
            CollectionAssert.Contains(proj.Assemblies, "string2");
            CollectionAssert.Contains(proj.Assemblies, "string3");
        }
Esempio n. 4
0
 public void SaveNullTest()
 {
     proj = new MbUnitProject();
     proj.Save(null);
 }
Esempio n. 5
0
 public void LoadNullTest()
 {
     proj = MbUnitProject.Load(null);
 }
Esempio n. 6
0
        public static TestDomainDependencyGraph BuildGraph(
            string[] testAssemblies,
            string[] assemblyPaths,
            IFixtureFilter fixtureFilter,
            IRunPipeFilter runPipeFilter,
            bool verbose
            )
        {
            // MLS 12/21/05 - adding verbose parameter to fix MBUNIT-28 (verbose command line option not working).
            // IDEA: A more flexible solution might be to pass in a collection of IRunPipeListeners.

            if (testAssemblies == null)
            {
                throw new ArgumentNullException("testAssemblies");
            }
            if (testAssemblies.Length == 0)
            {
                throw new ArgumentException("No assembly to test");
            }
            if (fixtureFilter == null)
            {
                throw new ArgumentNullException("fixtureFilter");
            }
            if (runPipeFilter == null)
            {
                throw new ArgumentNullException("runPipeFilter");
            }

            Hashtable loadedAssemblies      = new Hashtable();
            TestDomainDependencyGraph graph = null;

            try
            {
                graph         = new TestDomainDependencyGraph();
                graph.verbose = verbose;
                if (assemblyPaths != null)
                {
                    graph.AssemblyPaths.AddRange(assemblyPaths);
                }
                foreach (string testAssembly in testAssemblies)
                {
                    if (testAssembly.EndsWith(".mbunit"))
                    {
                        MbUnitProject project = MbUnitProject.Load(testAssembly);
                        foreach (string assembly in project.Assemblies)
                        {
                            if (loadedAssemblies.Contains(assembly))
                            {
                                continue;
                            }

                            TestDomain domain = new TestDomain(assembly);
                            domain.Filter        = fixtureFilter;
                            domain.RunPipeFilter = runPipeFilter;
                            graph.AddDomain(domain);
                            loadedAssemblies.Add(assembly, null);
                        }
                    }
                    else
                    {
                        if (loadedAssemblies.Contains(testAssembly))
                        {
                            continue;
                        }

                        TestDomain domain = new TestDomain(testAssembly);
                        domain.Filter        = fixtureFilter;
                        domain.RunPipeFilter = runPipeFilter;
                        graph.AddDomain(domain);
                        loadedAssemblies.Add(testAssembly, null);
                    }
                }
                graph.CreateDependencies();

                return(graph);
            }
            catch (System.Runtime.Remoting.RemotingException remote)
            {
                throw remote;
            }
            catch (Exception ex)
            {
                if (graph != null)
                {
                    graph.Dispose();
                    graph = null;
                }
                throw new ApplicationException("Failed loading assemblies", ex);
            }
        }