public void Hierarchy()
        {
            TestSuiteBuilder builder = new TestSuiteBuilder();
            Test suite = builder.Build( new TestPackage( testsDll ) );

            suite = (Test)suite.Tests[0];
            Assert.AreEqual("NUnit", suite.TestName.Name);

            suite = (Test)suite.Tests[0];
            Assert.AreEqual("Tests", suite.TestName.Name);
            Assert.AreEqual(MockAssembly.Fixtures, suite.Tests.Count);

            Test singletonSuite = TestFinder.Find("Singletons", suite, false);
            Assert.AreEqual(1, singletonSuite.Tests.Count);

            Test mockSuite = TestFinder.Find("Assemblies", suite, false);
            Assert.AreEqual(1, mockSuite.Tests.Count);

            Test mockFixtureSuite = TestFinder.Find("MockTestFixture", mockSuite, false);
            Assert.AreEqual(MockTestFixture.Tests, mockFixtureSuite.Tests.Count);

            foreach(Test t in mockFixtureSuite.Tests)
            {
                Assert.IsFalse(t.IsSuite, "Should not be a suite");
            }
        }
		public void SetUp() 
		{
			TestSuiteBuilder builder = new TestSuiteBuilder();
			suite = builder.Build( new TestPackage( testsDll ) );

			treeView = new TestSuiteTreeView();
		}
Beispiel #3
0
        /// <summary>
        /// Load a TestPackage
        /// </summary>
        /// <param name="package">The package to be loaded</param>
        /// <returns>True on success, false on failure</returns>
        public bool Load(TestPackage package)
        {
            log.Debug("Loading package " + package.Name);

            this.builder = new TestSuiteBuilder();

            _compatibility = package.GetSetting("NUnit3Compatibility", false);
            _workDirectory = package.GetSetting("WorkDirectory", Environment.CurrentDirectory);

            if (_compatibility)
            {
                Compatibility.BeginCollection(_workDirectory);
            }

            try
            {
                this.test = builder.Build(package);
            }
            finally
            {
                if (_compatibility)
                {
                    Compatibility.EndCollection();
                }
            }

            if (test == null)
            {
                return(false);
            }

            test.SetRunnerID(this.runnerID, true);
            TestExecutionContext.CurrentContext.TestPackage = package;
            return(true);
        }
 public void LoadTestFixtureFromAssembly()
 {
     TestSuiteBuilder builder = new TestSuiteBuilder();
     TestPackage package = new TestPackage( testsDll );
     package.TestName = "NUnit.Tests.Assemblies.MockTestFixture";
     Test suite= builder.Build( package );
     Assert.IsNotNull(suite);
 }
        public void CanAddAllAvailableCategoriesInTestTree()
        {
            TestSuiteBuilder builder = new TestSuiteBuilder();
            Test suite = builder.Build( new TestPackage( "mock-assembly.dll" ) );

            categoryManager.AddAllCategories( suite );
            //Assert.AreEqual( MockAssembly.Categories, categoryManager.Categories.Count );
        }
Beispiel #6
0
		public void Setup()
		{
			statusBar = new StatusBar();

			TestSuiteBuilder builder = new TestSuiteBuilder();
			suite = builder.Build( new TestPackage( testsDll ) );

			mockEvents = new MockTestEventSource( suite );
		}
        public void CanAddTestCategories()
        {
            TestSuiteBuilder builder = new TestSuiteBuilder();
            Test suite = builder.Build( new TestPackage( "mock-assembly.dll" ) );

            Test test = TestFinder.Find( "MockTest3", suite );
            categoryManager.AddCategories( test );
            Assert.AreEqual( 2, categoryManager.Categories.Count );
        }
Beispiel #8
0
        public void Setup()
        {
            progressBar = new TestProgressBar();

            TestSuiteBuilder builder = new TestSuiteBuilder();
            suite = new TestNode( builder.Build( new TestPackage( testsDll ) ) );

            mockEvents = new MockTestEventSource( suite );
        }
Beispiel #9
0
        /// <summary>
        /// Load a particular test in an assembly
        /// </summary>
        public Test Load(string assemblyName, string testName)
        {
            this.assemblies = new string[] { assemblyName };
            TestSuiteBuilder builder = new TestSuiteBuilder();

            suite            = builder.Build(assemblyName, testName);
            frameworkVersion = builder.FrameworkVersion;
            return(suite);
        }
Beispiel #10
0
        public Test Load(string projectName, string[] assemblies, string testName)
        {
            this.assemblies = (string[])assemblies.Clone();
            TestSuiteBuilder builder = new TestSuiteBuilder();

            suite            = builder.Build(assemblies, testName);
            frameworkVersion = builder.FrameworkVersion;
            return(suite);
        }
		private TestSuite PrepareTestSuite(List<String> assemblyList)
		{
			CoreExtensions.Host.InitializeService();
			var testPackage = new TestPackage("Unity",
												assemblyList);
			var builder = new TestSuiteBuilder();
			TestExecutionContext.CurrentContext.TestPackage = testPackage;
			TestSuite suite = builder.Build(testPackage);

			return suite;
		}
        public void NoNamespaceInAssembly()
        {
            TestSuiteBuilder builder = new TestSuiteBuilder();
            Test suite = builder.Build( new TestPackage( nonamespaceDLL ) );
            Assert.IsNotNull(suite);
            Assert.AreEqual( NoNamespaceTestFixture.Tests, suite.TestCount );

            suite = (TestSuite)suite.Tests[0];
            Assert.IsNotNull(suite);
            Assert.AreEqual( "NoNamespaceTestFixture", suite.TestName.Name );
            Assert.AreEqual( "NoNamespaceTestFixture", suite.TestName.FullName );
        }
        /// <summary>
        /// Load a TestPackage
        /// </summary>
        /// <param name="package">The package to be loaded</param>
        /// <returns>True on success, false on failure</returns>
        public bool Load(TestPackage package)
        {
            this.builder = new TestSuiteBuilder();

            this.test = builder.Build(package);
            if (test == null)
            {
                return(false);
            }

            test.SetRunnerID(this.runnerID, true);
            return(true);
        }
		public void RunMockTests()
		{
			string testsDll = NUnit.Tests.Assemblies.MockAssembly.AssemblyPath;
			TestSuiteBuilder suiteBuilder = new TestSuiteBuilder();
			Test suite = suiteBuilder.Build( new TestPackage( testsDll ) );

            TestResult result = suite.Run(NullListener.NULL, TestFilter.Empty);
			StringBuilder builder = new StringBuilder();
			new XmlResultWriter(new StringWriter(builder)).SaveTestResult(result);

			string resultXml = builder.ToString();

			resultDoc = new XmlDocument();
			resultDoc.LoadXml(resultXml);
		}
Beispiel #15
0
        /// <summary>
        /// Load a TestPackage
        /// </summary>
        /// <param name="package">The package to be loaded</param>
        /// <returns>True on success, false on failure</returns>
        public bool Load(TestPackage package)
        {
            log.Debug("Loading package " + package.Name);

            this.builder = new TestSuiteBuilder();

            this.test = builder.Build(package);
            if (test == null)
            {
                return(false);
            }

            test.SetRunnerID(this.runnerID, true);
            TestExecutionContext.CurrentContext.TestPackage = package;
            return(true);
        }
        public void Hierarchy()
        {
            TestSuiteBuilder builder = new TestSuiteBuilder();
            Test suite = builder.Build( new TestPackage( testsDll ) );
            IList tests = suite.Tests;
            Assert.AreEqual(1, tests.Count);

            Assert.IsTrue(tests[0] is TestSuite, "TestSuite:NUnit - is not correct");
            TestSuite testSuite = (TestSuite)tests[0];
            Assert.AreEqual("NUnit", testSuite.TestName.Name);

            tests = testSuite.Tests;
            Assert.IsTrue(tests[0] is TestSuite, "TestSuite:Tests - is invalid");
            testSuite = (TestSuite)tests[0];
            Assert.AreEqual(1, tests.Count);
            Assert.AreEqual("Tests", testSuite.TestName.Name);

            tests = testSuite.Tests;
            // TODO: Get rid of constants in this test
            Assert.AreEqual(MockAssembly.Fixtures, tests.Count);

            Assert.IsTrue(tests[3] is TestSuite, "TestSuite:singletons - is invalid");
            TestSuite singletonSuite = (TestSuite)tests[3];
            Assert.AreEqual("Singletons", singletonSuite.TestName.Name);
            Assert.AreEqual(1, singletonSuite.Tests.Count);

            Assert.IsTrue(tests[0] is TestSuite, "TestSuite:assemblies - is invalid");
            TestSuite mockSuite = (TestSuite)tests[0];
            Assert.AreEqual("Assemblies", mockSuite.TestName.Name);

            TestSuite mockFixtureSuite = (TestSuite)mockSuite.Tests[0];
            Assert.AreEqual(MockTestFixture.Tests, mockFixtureSuite.Tests.Count);

            IList mockTests = mockFixtureSuite.Tests;
            foreach(Test t in mockTests)
            {
                Assert.IsTrue(t is NUnit.Core.TestCase, "should be a TestCase");
            }
        }
        /// <summary>
        /// InitPluginModule : called at plugin initialisation time: Add the relevant shape creators here
        /// </summary>
        public override bool InitPluginModule()
        {
            TerrainManaged.ManagedModule.InitManagedModule();
              EDITOR_PLUGIN_INFO.NativePluginNames = new string[] { "VisionEnginePlugin" };

            TerrainEditor.Init();

              // Add IShapeCreatorPlugin
            _heightFieldCreator = new TerrainShapeCreator();
            EditorManager.ShapeCreatorPlugins.Add(_heightFieldCreator);

              // add default filter:
              TerrainEditor.HeightmapImporterList.Add(new ImportHeightmapTEX16bpp());
              TerrainEditor.HeightmapImporterList.Add(new ImportHeightmapRAW());
              TerrainEditor.HeightmapImporterList.Add(new ImportHeightmapDDS());

              TerrainEditor.HeightmapFilterList.Add(new HeightmapClearFilter());
              TerrainEditor.HeightmapFilterList.Add(new HeightmapScaleElevateFilter());

              TerrainEditor.DecorationFilterList.Add(new DecorationClearFilter());
              TerrainEditor.DecorationFilterList.Add(new DecorationImportFromLuminanceFilter());
              TerrainEditor.DecorationFilterList.Add(new DecorationFromDetailTextureFilter());
              TerrainEditor.DecorationFilterList.Add(new DecorationFromSlopeFilter());

            // create panel
            _panel = new TerrainEditorPanel(EditorManager.ApplicationLayout.DockingArea);
            _panel.ShowDockable();
              TerrainEditor.EditorPanel = _panel;

              // register tests:
              TestSuiteBuilder testBuilder = new TestSuiteBuilder();
              TestSuite testSuite = testBuilder.Build(typeof(EditorPlugin).Assembly.FullName);
              TestManager.AddTestSuite(testSuite);

              return true;
        }
Beispiel #18
0
		/// <summary>
		/// Load a particular test in an assembly
		/// </summary>
		public Test Load( string assemblyName, string testName )
		{
			this.assemblies = new string[] { assemblyName };
			TestSuiteBuilder builder = new TestSuiteBuilder();
			suite = builder.Build( assemblyName, testName );
			frameworkVersion = builder.FrameworkVersion;
			return suite;
		}
        public void CanReloadAfterTurningOffAutoNamespaces()
        {
            TestSuiteBuilder builder = new TestSuiteBuilder();
            TestPackage package = new TestPackage(testsDll);
            package.Settings["AutoNamespaceSuites"] = false;
            TestSuite suite2 = builder.Build(package);
            Assert.AreEqual(originalTestCount, suite2.TestCount);
            Assert.AreEqual(MockAssembly.Classes, suite2.Tests.Count);

            ReassignTestIDsAndReload(suite2);
            CheckTreeAgainstSuite(suite2, "after turning automatic namespaces OFF");

            // TODO: This currently doesn't work
            //ReassignTestIDsAndReload(suite);
            //CheckTreeAgainstSuite(suite, "after turning automatic namespaces ON");
        }
        private static void RunNUnitTests(string type, string uuid)
        {
            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
            List<string> assemblyLocations = new List<string>();
            foreach (Assembly t in assemblies)
            {
                string fullName = t.FullName;
                if(fullName.Contains("Assembly-CSharp-Editor") || fullName.Contains("Assembly-UnityScript-Editor"))
                {
                    assemblyLocations.Add(t.Location);
                }
            }

            CoreExtensions.Host.InitializeService(); // need initialize service

            TestPackage testPackage = new TestPackage(PlayerSettings.productName, assemblyLocations);

            TestExecutionContext.CurrentContext.TestPackage = testPackage;

            TestSuiteBuilder builder = new TestSuiteBuilder();

            TestSuite testSuite = builder.Build(testPackage);

            if(testSuite == null)
            {
                EditorUtility.DisplayDialog(PluginConstants.ourDialogTitle, "Suite is null", "OK");
                return;
            }

            WebApiServer.ourCurrentTestUUID = uuid;

            testSuite.Run(new NUnitTestListener(uuid), TestFilter.Empty);

            WebApiServer.ourCurrentTestUUID = null;
            WebApiServer.ourCurrentTestName = null;

            TestExecutionContext.CurrentContext.TestPackage = null;
        }
Beispiel #21
0
 public IList<TestUnitWithMetadata> Get(TestPackage package, TestRun testRun)
 {
     new NUnitInitializer().Initialize();
     var builder = new TestSuiteBuilder();
     TestSuite testSuite = builder.Build(package);
     var filter = new NUnitTestsFilter(testRun.NUnitParameters.IncludeCategories,
                                       testRun.NUnitParameters.ExcludeCategories,
                                       testRun.NUnitParameters.TestToRun);
     return ToTestUnitList(testSuite, filter, testRun);
 }
        /// <summary>
        /// Overridden function that gets called when the plugin is loaded. Registers all creator plugins
        /// </summary>
        /// <returns></returns>
        public override bool InitPluginModule()
        {
            EDITOR_PLUGIN_INFO.NativePluginNames = new string[] { "Havok Ai" };
              HavokAiManaged.ManagedModule.InitManagedModule();

              // register shape class
              creators = new IShapeCreatorPlugin[]
              {
              new HavokNavMeshShapeCreator(),
              new HavokNavMeshCarverShapeCreator(),
              new HavokNavMeshSeedPointShapeCreator(),
              new HavokNavMeshLocalSettingsShapeCreator(),
              new HavokNavMeshTestPathShapeCreator()
              };
              foreach (IShapeCreatorPlugin plugin in creators)
              {
            EditorManager.ShapeCreatorPlugins.Add(plugin);
              }

              // create and activate panel
              _panel = new HavokAiPanel(EditorManager.ApplicationLayout.DockingArea);
              _panel.ShowDockable();
              _panel.Enabled = false;

              // register callbacks
              IScene.ShapeChanged += new ShapeChangedEventHandler(IScene_ShapeChanged);
              IScene.PropertyChanged += new PropertyChangedEventHandler(IScene_PropertyChanged);
              IScene.EngineInstancesChanged += new EngineInstancesChangedEventHandler(IScene_EngineInstancesChanged);
              EditorManager.SceneChanged += new SceneChangedEventHandler(EditorManager_SceneChanged);
              EditorManager.ShapeSelectionChanged += new ShapeSelectionChangedEventHandler(EditorManager_ShapeSelectionChanged);
              EditorManager.EditorModeChanged += new EditorModeChangedEventHandler(EditorManager_EditorModeChanged);

              // Register automated tests
              TestSuiteBuilder testBuilder = new TestSuiteBuilder();
              TestSuite testSuite = testBuilder.Build(typeof(EditorPlugin).Assembly.FullName);
              TestManager.AddTestSuite(testSuite);

              return true;
        }
		/// <summary>
		/// Load a TestPackage
		/// </summary>
		/// <param name="package">The package to be loaded</param>
		/// <returns>True on success, false on failure</returns>
		public bool Load( TestPackage package )
		{
			this.builder = new TestSuiteBuilder();

			this.test = builder.Build( package );
			if ( test == null ) return false;

			test.SetRunnerID( this.runnerID, true );
			return true;
		}
		public void LoadSuite()
		{
			builder = new TestSuiteBuilder();
			loadedSuite = builder.Build( new TestPackage( "TestSuite", assemblies ) );
		}
Beispiel #25
0
        public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
        {
            AppDomain.CurrentDomain.AssemblyResolve += Dynamo.Utilities.AssemblyHelper.CurrentDomain_AssemblyResolve;

            //Get the data map from the running journal file.
            IDictionary<string, string> dataMap = revit.JournalData;

            try
            {
                RevitData.Application = revit.Application;
                RevitData.Document = RevitData.Application.ActiveUIDocument;

                bool canReadData = (0 < dataMap.Count);

                if (canReadData)
                {
                    if (dataMap.ContainsKey("testName"))
                    {
                        testName = dataMap["testName"];
                    }
                    if (dataMap.ContainsKey("fixtureName"))
                    {
                        fixtureName = dataMap["fixtureName"];
                    }
                    if (dataMap.ContainsKey("testAssembly"))
                    {
                        testAssembly = dataMap["testAssembly"];
                    }
                    if (dataMap.ContainsKey("resultsPath"))
                    {
                        resultsPath = dataMap["resultsPath"];
                    }
                    if (dataMap.ContainsKey("runDynamo"))
                    {
                        runDynamo = Convert.ToBoolean(dataMap["runDynamo"]);
                    }
                }

                if (string.IsNullOrEmpty(testAssembly))
                {
                    throw new Exception("Test assembly location must be specified in journal.");
                }

                if (string.IsNullOrEmpty(resultsPath))
                {
                    throw new Exception("You must supply a path for the results file.");
                }

                if (runDynamo)
                {
                    StartDynamo();
                }

                //http://stackoverflow.com/questions/2798561/how-to-run-nunit-from-my-code

                //Tests must be executed on the main thread in order to access the Revit API.
                //NUnit's SimpleTestRunner runs the tests on the main thread
                //http://stackoverflow.com/questions/16216011/nunit-c-run-specific-tests-through-coding?rq=1
                CoreExtensions.Host.InitializeService();
                var runner = new SimpleTestRunner();
                var builder = new TestSuiteBuilder();
                string testAssemblyLoc = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), testAssembly);

                var package = new TestPackage("DynamoTestFramework", new List<string>() {testAssemblyLoc});
                runner.Load(package);
                TestSuite suite = builder.Build(package);

                TestFixture fixture = null;
                FindFixtureByName(out fixture, suite, fixtureName);
                if (fixture == null)
                    throw new Exception(string.Format("Could not find fixture: {0}", fixtureName));

                InitializeResults();

                if (!canReadData)
                {
                    var currInvalid = Convert.ToInt16(resultsRoot.invalid);
                    resultsRoot.invalid = currInvalid + 1;
                    resultsRoot.testsuite.result = "Error";

                    throw new Exception("Journal file's data map contains no information about tests.");
                }

                //find or create a fixture
                var fixtureResult = FindOrCreateFixtureResults(dynamoResults, fixtureName);

                //convert the fixture's results array to a list
                var runningResults = fixtureResult.results.Items.ToList();

                //if the test name is not specified
                //run all tests in the fixture
                if (string.IsNullOrEmpty(testName) || testName == "None")
                {
                    var fixtureResults = RunFixture(fixture);
                    runningResults.AddRange(fixtureResults);
                }
                else
                {
                    var t = FindTestByName(fixture, testName);
                    if (t != null)
                    {
                        if (t is ParameterizedMethodSuite)
                        {
                            var paramSuite = t as ParameterizedMethodSuite;
                            foreach (var tInner in paramSuite.Tests)
                            {
                                if (tInner is TestMethod)
                                {
                                    runningResults.Add(RunTest((TestMethod)tInner));
                                }
                            }
                        }
                        else if (t is TestMethod)
                        {
                            runningResults.Add(RunTest((TestMethod)t));
                        }
                    }
                    else
                    {
                        //we have a journal file, but the specified test could not be found
                        var currInvalid = Convert.ToInt16(resultsRoot.invalid);
                        resultsRoot.invalid = currInvalid + 1;
                        resultsRoot.testsuite.result = "Error";
                    }
                }

                fixtureResult.results.Items = runningResults.ToArray();

                CalculateCaseTotalsOnSuite(fixtureResult);
                CalculateSweetTotalsOnOuterSweet(rootSuite);
                CalculateTotalsOnResultsRoot(resultsRoot);

                SaveResults();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.StackTrace);
                return Result.Failed;
            }

            return Result.Succeeded;
        }
		/// <summary>
		/// Load a TestPackage
		/// </summary>
		/// <param name="package">The package to be loaded</param>
		/// <returns>True on success, false on failure</returns>
		public bool Load( TestPackage package )
		{
            log.Debug("Loading package " + package.Name);

			this.builder = new TestSuiteBuilder();

			this.test = builder.Build( package );
			if ( test == null ) return false;

			test.SetRunnerID( this.runnerID, true );
            TestExecutionContext.CurrentContext.TestPackage = package;
			return true;
		}
Beispiel #27
0
        private testsuiteType RunTests(bool canReadData)
        {
            //http://stackoverflow.com/questions/2798561/how-to-run-nunit-from-my-code

            //Tests must be executed on the main thread in order to access the Revit API.
            //NUnit's SimpleTestRunner runs the tests on the main thread
            //http://stackoverflow.com/questions/16216011/nunit-c-run-specific-tests-through-coding?rq=1
            CoreExtensions.Host.InitializeService();
            var runner = new SimpleTestRunner();
            var builder = new TestSuiteBuilder();
            string testAssemblyLoc = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), testAssembly);

            var package = new TestPackage("RevitTestFramework", new List<string>() {testAssemblyLoc});
            runner.Load(package);
            TestSuite suite = builder.Build(package);

            TestFixture fixture = null;
            FindFixtureByName(out fixture, suite, fixtureName);
            if (fixture == null)
                throw new Exception(string.Format("Could not find fixture: {0}", fixtureName));

            InitializeResults();

            // If we can't read data, add a failed test result to root.
            if (!canReadData)
            {
                var currInvalid = Convert.ToInt16(resultsRoot.invalid);
                resultsRoot.invalid = currInvalid + 1;
                resultsRoot.testsuite.result = "Error";

                throw new Exception("Journal file's data map contains no information about tests.");
            }

            //find or create a fixture
            var fixtureResult = FindOrCreateFixtureResults(dynamoResults, fixtureName);

            //convert the fixture's results array to a list
            var runningResults = fixtureResult.results.Items.ToList();

            //if the test name is not specified
            //run all tests in the fixture
            if (string.IsNullOrEmpty(testName) || testName == "None")
            {
                var fixtureResults = RunFixture(fixture);
                runningResults.AddRange(fixtureResults);
            }
            else
            {
                var t = FindTestByName(fixture, testName);
                if (t != null)
                {
                    if (t is ParameterizedMethodSuite)
                    {
                        var paramSuite = t as ParameterizedMethodSuite;
                        runningResults.AddRange(
                            paramSuite.Tests.OfType<TestMethod>()
                                .Select(RunTest).Cast<object>());
                    }
                    else
                    {
                        var method = t as TestMethod;
                        if (method != null)
                        {
                            runningResults.Add(RunTest(method));
                        }
                    }
                }
                else
                {
                    //we have a journal file, but the specified test could not be found
                    var currInvalid = Convert.ToInt16(resultsRoot.invalid);
                    resultsRoot.invalid = currInvalid + 1;
                    resultsRoot.testsuite.result = "Error";
                }
            }

            fixtureResult.results.Items = runningResults.ToArray();
            return fixtureResult;
        }
        /// <summary>
        /// Overridden function that gets called when the plugin is loaded. Registers all creator plugins
        /// </summary>
        /// <returns></returns>
        public override bool InitPluginModule()
        {
            VisionManaged.ManagedModule.InitManagedModule();
              EDITOR_PLUGIN_INFO.NativePluginNames = new string[] { "VisionEnginePlugin" };

              // listen to the following events
              IProject.NewProjectLoaded += new EventHandler(IProject_NewProjectLoaded);
              IProject.ProjectUnloaded += new EventHandler(IProject_ProjectUnloaded);
              EditorManager.SceneChanged += new SceneChangedEventHandler(EditorManager_SceneChanged);
              EditorManager.SceneEvent += new SceneEventHandler(EditorManager_SceneEvent);
              EditorManager.ProcessExternalFileDrop += new ExternalFileDropHandler(EditorManager_ProcessExternalFileDrop);
              EditorManager.QueryDragDropContext += new QueryDragDropContextEventHandler(EditorManager_QueryDragDropContext);

              // make this globally available
              PrefabDesc.PrefabInstanceCreator = new PrefabShapeCreator();

              // register shape classes
              creators = new IShapeCreatorPlugin[]
                 {
                  new EntityCreator(),
                  new OmniLightCreator(false),
                  new SpotLightCreator(false),
                  new DirectionalLightCreator(false),
                  new OmniLightCreator(true),
                  new SpotLightCreator(true),
                  new DirectionalLightCreator(true),
                  new TimeOfDaySunCreator(),

                  new ParticleSystemCreator(),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.GroundPlane),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.Plane),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.Sphere),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.AABox),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.XAxis),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.YAxis),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.ZAxis),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.Fan),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.Cyclone),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.Point),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.GravityPoint),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.Terrain),
                  new ConstraintCreator(EngineInstanceConstraint.ConstraintType_e.CameraBox),

                  new ProjectorShapeCreator(),
                  new ClothObjectCreator(),
                  new MirrorCreator(),
                  new VisibilityObjectCreator(),
                  new LightGridBoxCreator(),
                  new LightGridDetailBoxCreator(),
                  new LightGridIndicatorCreator(),
                  new PathShapeCreator(),
                  new CircleShapeCreator(),
                  new PathCameraShapeCreator(),
                  new CameraPositionShapeCreator(),

                  //new RenderTargetShapeCreator(), // still port engine instance
                  new CubemapShapeCreator(),
                  //new PostProcessingShapeCreator(),

                  PrefabDesc.PrefabInstanceCreator,
                  new StaticMeshShapeCreator(),
                  new StaticMeshGroupShapeCreator(),
                  new TriggerBoxShapeCreator(),
                  new BillboardGroupShapeCreator(),
                  new CustomVolumeShapeCreator(),

            #if !HK_ANARCHY
                  new CloudLayerCreator(),
                  new DecorationGroupCreator(),
                  new WaterCreator(),
                  new SunglareCreator(),
                  new VolumetricConeCreator(),
                  new FogObjectCreator(),
                  new ProjectedDecalCreator(),
            #endif
                  };

              foreach (IShapeCreatorPlugin plugin in creators)
            EditorManager.ShapeCreatorPlugins.Add( plugin );

              // Add lightmap tweaking menu item
              // this is not supported ATM, because lightmaps are not in a central place anymore
              //lightmapMenuItemPlugin = new LightmapMenuItemPlugin();
              //EditorManager.AddMenuItemPlugin(lightmapMenuItemPlugin);

              _colorGradingTool = new ColorGradingToolPlugin();
              EditorManager.AddMenuItemPlugin(_colorGradingTool);

              PrefabManager.BINARY_SAVER = new VisionPrefabBinarySaver();
              VisionEngineManager.EntityClassManagerType = typeof(EntityClassManager);

              // register tests
              TestSuiteBuilder testBuilder = new TestSuiteBuilder();
              TestSuite testSuite = testBuilder.Build(typeof(EditorPlugin).Assembly.FullName);
              TestManager.AddTestSuite(testSuite);
              return true;
        }
Beispiel #29
0
        public void RunMockTests()
        {
            string testsDll = "mock-assembly.dll";
            TestSuiteBuilder suiteBuilder = new TestSuiteBuilder();
            Test suite = suiteBuilder.Build( new TestPackage( testsDll ) );

            TestResult result = suite.Run(NullListener.NULL);
            StringBuilder builder = new StringBuilder();
            StringWriter writer = new StringWriter(builder);
            XmlResultVisitor visitor = new XmlResultVisitor(writer, result);
            result.Accept(visitor);
            visitor.Write();

            string resultXml = builder.ToString();
            Console.WriteLine(resultXml);

            resultDoc = new XmlDocument();
            resultDoc.LoadXml(resultXml);
        }
Beispiel #30
0
        public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
        {
            DynamoLogger.Instance.StartLogging();

            try
            {
                m_revit = revit.Application;
                m_doc = m_revit.ActiveUIDocument;

                #region default level

                Level defaultLevel = null;
                var fecLevel = new FilteredElementCollector(m_doc.Document);
                fecLevel.OfClass(typeof(Level));
                defaultLevel = fecLevel.ToElements()[0] as Level;

                #endregion

                dynRevitSettings.Revit = m_revit;
                dynRevitSettings.Doc = m_doc;
                dynRevitSettings.DefaultLevel = defaultLevel;

                //create dynamo
                Regex r = new Regex(@"\b(Autodesk |Structure |MEP |Architecture )\b");
                string context = r.Replace(m_revit.Application.VersionName, "");

                var dynamoController = new DynamoController_Revit(DynamoRevitApp.env, DynamoRevitApp.updater, typeof(DynamoRevitViewModel), context);

                //flag to run evalauation synchronously, helps to
                //avoid threading issues when testing.
                dynamoController.Testing = true;

                //execute the tests
                Results = new DynamoRevitTestRunner();
                DynamoRevitTestResultsView resultsView = new DynamoRevitTestResultsView();
                resultsView.DataContext = Results;

                //http://stackoverflow.com/questions/2798561/how-to-run-nunit-from-my-code
                string assLocation = Assembly.GetExecutingAssembly().Location;
                FileInfo fi = new FileInfo(assLocation);
                string testLoc = Path.Combine(fi.DirectoryName, @"DynamoRevitTester.dll");

                //Tests must be executed on the main thread in order to access the Revit API.
                //NUnit's SimpleTestRunner runs the tests on the main thread
                //http://stackoverflow.com/questions/16216011/nunit-c-run-specific-tests-through-coding?rq=1
                CoreExtensions.Host.InitializeService();
                SimpleTestRunner runner = new SimpleTestRunner();
                TestSuiteBuilder builder = new TestSuiteBuilder();
                TestPackage package = new TestPackage("DynamoRevitTests", new List<string>() { testLoc });
                runner.Load(package);
                TestSuite suite = builder.Build(package);
                TestFixture fixture = null;
                FindFixtureByName(out fixture, suite, "DynamoRevitTests");
                if (fixture == null)
                    throw new Exception("Could not find DynamoRevitTests fixture.");

                foreach (var t in fixture.Tests)
                {
                    if (t is ParameterizedMethodSuite)
                    {
                        var paramSuite = t as ParameterizedMethodSuite;
                        foreach (var tInner in paramSuite.Tests)
                        {
                            if (tInner is TestMethod)
                                Results.Results.Add(new DynamoRevitTest(tInner as TestMethod));
                        }
                    }
                    else if (t is TestMethod)
                        Results.Results.Add(new DynamoRevitTest(t as TestMethod));
                }

                resultsView.ShowDialog();

            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                return Result.Failed;
            }

            return Result.Succeeded;
        }
 public void TestRoot()
 {
     TestSuiteBuilder builder = new TestSuiteBuilder();
     Test suite = builder.Build( new TestPackage( testsDll ) );
     Assert.AreEqual(testsDll, suite.TestName.Name);
 }
        /// <summary>
        /// Overridden function that gets called when the plugin is loaded. Registers all creator plugins
        /// </summary>
        /// <returns></returns>
        public override bool InitPluginModule()
        {
            EDITOR_PLUGIN_INFO.NativePluginNames = new string[] { "Havok Behavior" };
            HavokBehaviorManaged.ManagedModule.InitManagedModule();

            // Register automated tests
            TestSuiteBuilder testBuilder = new TestSuiteBuilder();
            TestSuite testSuite = testBuilder.Build(typeof(EditorPlugin).Assembly.FullName);
            TestManager.AddTestSuite(testSuite);
            return true;
        }
Beispiel #33
0
        static int Main( string[] args )
        {
            // should be the first thing to call.
              // This feature activates Group display in list views for instance.
              // Observe in the future: Is this the cause for any SEHException or strange UI behavior?

              Application.EnableVisualStyles();
              //Application.DoEvents(); // recommended in the web to avoid misc problems

              // set all possible types of culture type to avoid decimal comma in UI and prefab(!) .ToString functions
              CultureInfo culture = new System.Globalization.CultureInfo("en-US");

              // some of these are probably duplicates, but anyway...
              System.Threading.Thread.CurrentThread.CurrentCulture = culture;
              Application.CurrentCulture = culture;
              Thread.CurrentThread.CurrentCulture = culture;
              Thread.CurrentThread.CurrentUICulture = culture; // this seems responsible for number.ToString problems

              // initialize DLLs
              // int retval = ManagedFramework.ManagedFramework.minitialize() ;

              // register ManagedFramework tests in test manager
              TestSuiteBuilder testBuilder = new TestSuiteBuilder();
              TestSuite testSuiteManagedFrameWork = testBuilder.Build( typeof(ManagedFramework.VisionEngineManager).Assembly.FullName );
              TestManager.AddTestSuite(testSuiteManagedFrameWork);

              // register editor tests in test manager
              testBuilder = new TestSuiteBuilder();
              TestSuite testSuite = testBuilder.Build( typeof(EditorApp).Assembly.FullName );
              TestManager.AddTestSuite(testSuite);

              // parse command line for automated tests
              if (args.Length == 1 && args[0] == "-test")
            g_triggerTests = true;

              // this is our workaround:
              EditorManager.DesignMode = false;

              // we must ensure that the CWD is the EXE dir, otherwise we get lots of problems (bitmap files etc.)
              string sEXEDir = Application.StartupPath;
              Directory.SetCurrentDirectory(sEXEDir);

              Form1 form = new Form1();
              form.CommandLineArgs = args; // store them and parse them a bit later (first time in OnVisibleChanged)

            #if (!DEBUG)
              AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Domain_UnhandledException);
              Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

              try
            #endif
              {
            // run application
            Application.Run(form);
              }
            #if (!DEBUG)
              catch (Exception ex)
              {
            EditorManager.DumpException(ex, true);
              }
            #endif

              EditorApp.DeinitEditorApp();

              if (g_triggerTests)
            return (g_testResult ? 0 : -1);

              // deinit DLLs
              //ManagedFramework.ManagedFramework.mterminate();

              return 0;
        }
Beispiel #34
0
		public Test Load( string projectName, string[] assemblies, string testName )
		{
			this.assemblies = (string[])assemblies.Clone();
			TestSuiteBuilder builder = new TestSuiteBuilder();
			suite = builder.Build( assemblies, testName );
			frameworkVersion = builder.FrameworkVersion;
			return suite;
		}
        /// <summary>
        /// Overridden function that gets called when the plugin is loaded. Registers all creator plugins
        /// </summary>
        /// <returns></returns>
        public override bool InitPluginModule()
        {
            EDITOR_PLUGIN_INFO.NativePluginNames = new string[] { "Havok" };
              HavokManaged.ManagedModule.InitManagedModule();

              StaticMeshShape.UsesCollisionGroups = true; // switch to displaying collision groups

              // register shape classes
              creators = new IShapeCreatorPlugin[]
                 {
                   new HavokConstraintShapeCreator(),
                   new HavokConstraintChainShapeCreator(),
                   new HavokResourceShapeCreator()
                 };

              foreach (IShapeCreatorPlugin plugin in creators)
            EditorManager.ShapeCreatorPlugins.Add( plugin );

              // create and activate panel
              _panel = new HavokPhysicsPanel(EditorManager.ApplicationLayout.DockingArea);
              _panel.ShowDockable();

              // Register automated tests
              TestSuiteBuilder testBuilder = new TestSuiteBuilder();
              TestSuite testSuite = testBuilder.Build(typeof(EditorPlugin).Assembly.FullName);
              TestManager.AddTestSuite(testSuite);

              IProject.ProjectUnloaded += new EventHandler(IProject_ProjectUnloaded);

              return true;
        }