public void AddAssembly_GivenNullAssembly_ShouldThrowException()
 {
     //---------------Set up test pack-------------------
     AssemblyExplorer explorer = new AssemblyExplorer();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     ArgumentNullException exception = Assert.Throws<ArgumentNullException>(() => explorer.AddAssembly(null));
     //---------------Test Result -----------------------
     Assert.AreEqual("assembly", exception.ParamName);
 }
 public void AddAssembly_GivenValidAssembly_ShouldDiscoverPublicTypes()
 {
     //---------------Set up test pack-------------------
     AssemblyExplorer explorer = new AssemblyExplorer();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     explorer.AddAssembly(typeof(TestAssemblyExplorer).Assembly);
     bool hasPublicType = explorer.Types.Contains(typeof(TestAssemblyExplorer));
     //---------------Test Result -----------------------
     Assert.IsTrue(hasPublicType);
 }
 public void AddAssembly_GivenAddedTwoEqualAssemblies_ShouldNotReAddTypes()
 {
     //---------------Set up test pack-------------------
     AssemblyExplorer explorer = new AssemblyExplorer();
     Assembly assembly = typeof(TestAssemblyExplorer).Assembly;
     explorer.AddAssembly(assembly);
     //---------------Assert Precondition----------------
     Assert.AreNotEqual(0, explorer.Types.Count);
     //---------------Execute Test ----------------------
     int expectedNumberOfTypes = explorer.Types.Count;
     explorer.AddAssembly(assembly);
     //---------------Test Result -----------------------
     Assert.AreEqual(expectedNumberOfTypes, explorer.Types.Count);
 }
 public void AddAssembly_GivenAddedTwoDifferentAssemblies_ShouldAddTypesFromBoth()
 {
     //---------------Set up test pack-------------------
     AssemblyExplorer explorer = new AssemblyExplorer();
     explorer.AddAssembly(typeof(TestAssemblyExplorer).Assembly);
     Assembly assembly = typeof(AssemblyExplorer).Assembly;
     //---------------Assert Precondition----------------
     Assert.AreNotEqual(0, explorer.Types.Count);
     //---------------Execute Test ----------------------
     int numberOfTypesBeforeAddition = explorer.Types.Count;
     explorer.AddAssembly(assembly);
     //---------------Test Result -----------------------
     Assert.AreNotEqual(numberOfTypesBeforeAddition, explorer.Types.Count);
 }
Example #5
0
 public DefaultRunner(ISpecificationRunListener listener, RunOptions options)
 {
     _listener = listener;
     _options  = options;
     _explorer = new AssemblyExplorer();
 }
        public void ExploreAssembly(IMetadataAssembly assembly, IProject project, UnitTestElementConsumer consumer)
        {
            AssemblyExplorer explorer = new AssemblyExplorer(this, assembly, project, consumer);

            explorer.Explore();
        }
Example #7
0
        public void Parse(object path)
        {
            if (!(path is string) || String.IsNullOrEmpty((string)path))
            {
                MessageBox.Show("Can't read installation path from Registry\nLocalMachine/Software/gViewGisOS/Install_Dir", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DirectoryInfo di;

            try
            {
                di = new DirectoryInfo((string)path);
                if (!di.Exists)
                {
                    return;
                }
            }
            catch { return; }

            AssemblyExplorer explorer = new AssemblyExplorer();

            explorer.AddPlugin          += new AssemblyExplorer.AddPluginEvent(explorer_AddPlugin);
            explorer.AddPluginException += new AssemblyExplorer.AddPluginExceptionEvent(explorer_AddPluginException);

            FileInfo[] fis = di.GetFiles("*.dll");

            int pos = 1;

            foreach (FileInfo ass in fis)
            {
                if (ParseAssembly != null)
                {
                    ParseAssembly(ass.FullName, pos, fis.Length);
                }

                string xml = explorer.Explore(ass.FullName);

                if (!String.IsNullOrEmpty(xml))
                {
                    try
                    {
                        addComponent(ass.FullName);
                        if (AddComponent != null)
                        {
                            AddComponent(ass.FullName);
                        }
                        writeComponents();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (xml == null) // Canceled...
                {
                    break;
                }
                pos++;
            }
            if (Finished != null)
            {
                Finished();
            }
        }
 private Controller(Action <string> listenCallback, RunOptions runOptions)
 {
     _listener = new ControllerRunListener(listenCallback);
     _explorer = new AssemblyExplorer();
     _runner   = new DefaultRunner(_listener, runOptions, signalRunStartAndEnd: false);
 }
 public void Clone_GivenCloneIsModified_ShouldNotAffectOriginalExplorer()
 {
     //---------------Set up test pack-------------------
     AssemblyExplorer originalExplorer = new AssemblyExplorer();
     originalExplorer.AddAssembly(typeof(TestAssemblyExplorer).Assembly);
     //---------------Assert Precondition----------------
     Assert.IsNotEmpty(originalExplorer.Types);
     //---------------Execute Test ----------------------
     AssemblyExplorer clonedExplorer = originalExplorer.Clone();
     //---------------Test Result -----------------------
     CollectionAssert.AreEquivalent(originalExplorer.Types, clonedExplorer.Types);
     clonedExplorer.AddAssembly<AssemblyExplorer>();
     CollectionAssert.AreNotEquivalent(originalExplorer.Types, clonedExplorer.Types);
 }
 private static AssemblyExplorer CreateExplorer()
 {
     AssemblyExplorer result = new AssemblyExplorer();
     result.AddAssembly(typeof(TestAssemblyExplorer).Assembly);
     return result;
 }
 public void Clone_GivenExpectedTypes_ShouldCreateIdenticalExplorerWithExpectedTypes()
 {
     //---------------Set up test pack-------------------
     AssemblyExplorer originalExplorer = new AssemblyExplorer();
     originalExplorer.AddAssembly(typeof(TestAssemblyExplorer).Assembly);
     //---------------Assert Precondition----------------
     Assert.IsNotEmpty(originalExplorer.Types);
     //---------------Execute Test ----------------------
     AssemblyExplorer clonedExplorer = originalExplorer.Clone();
     //---------------Test Result -----------------------
     CollectionAssert.AreEquivalent(originalExplorer.Types, clonedExplorer.Types);
 }