Ejemplo n.º 1
0
        public void Regressions(RegressionTestData testData)
        {
            Exception exception = null;

            try
            {
                var dynamoFilePath = testData.Arguments[0].ToString();
                var revitFilePath  = testData.Arguments[1].ToString();

                //ensure that the incoming arguments are not empty or null
                //if a dyn file is found in the regression tests directory
                //and there is no corresponding rfa or rvt, then an empty string
                //or a null will be passed into here.
                Assert.IsNotNullOrEmpty(dynamoFilePath, "Dynamo file path is invalid or missing.");
                Assert.IsNotNullOrEmpty(revitFilePath, "Revit file path is invalid or missing.");

                //open the revit model
                SwapCurrentModel(revitFilePath);

                //Ensure SystemTestBase picks up the right directory.
                pathResolver = new RevitTestPathResolver();
                (pathResolver as RevitTestPathResolver).InitializePreloadedLibraries();

                //Setup should be called after swapping document, so that RevitDynamoModel
                //is now associated with swapped model.
                Setup();

                //open the dyn file
                ViewModel.OpenCommand.Execute(dynamoFilePath);
                Assert.IsTrue(ViewModel.Model.CurrentWorkspace.Nodes.Count > 0);
                AssertNoDummyNodes();

                //run the expression and assert that it does not
                //throw an error

                RunCurrentModel();

                var errorNodes =
                    ViewModel.Model.CurrentWorkspace.Nodes.Where(
                        x => x.State == ElementState.Error || x.State == ElementState.Warning);
                Assert.AreEqual(0, errorNodes.Count());
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            finally
            {
                ViewModel.Model.ShutDown(false);
                ViewModel = null;
                RevitServicesUpdater.DisposeInstance();
                TearDown();
            }

            if (exception != null)
            {
                Assert.Fail(exception.Message);
            }
        }
Ejemplo n.º 2
0
        public void Regressions(RegressionTestData testData)
        {
            Exception exception = null;

            try
            {
                var dynamoFilePath = testData.Arguments[0].ToString();
                var revitFilePath = testData.Arguments[1].ToString();

                Setup();

                //ensure that the incoming arguments are not empty or null
                //if a dyn file is found in the regression tests directory
                //and there is no corresponding rfa or rvt, then an empty string
                //or a null will be passed into here.
                Assert.IsNotNullOrEmpty(dynamoFilePath, "Dynamo file path is invalid or missing.");
                Assert.IsNotNullOrEmpty(revitFilePath, "Revit file path is invalid or missing.");

                //open the revit model
                SwapCurrentModel(revitFilePath);

                //open the dyn file
                ViewModel.OpenCommand.Execute(dynamoFilePath);

                //run the expression and assert that it does not
                //throw an error
                Assert.DoesNotThrow(() => ViewModel.Model.RunExpression());
                var errorNodes =
                    ViewModel.Model.Nodes.Where(
                        x => x.State == ElementState.Error || x.State == ElementState.Warning);
                Assert.AreEqual(0, errorNodes.Count());
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            finally
            {
                ViewModel.Model.ShutDown(false);
                ViewModel = null;
                Teardown();
            }

            if (exception != null)
            {
                Assert.Fail(exception.Message);
            }
        }
Ejemplo n.º 3
0
        public void Regressions(RegressionTestData testData)
        {
            Exception exception = null;

            try
            {
                var dynamoFilePath = testData.Arguments[0].ToString();
                var revitFilePath  = testData.Arguments[1].ToString();

                Setup();

                //ensure that the incoming arguments are not empty or null
                //if a dyn file is found in the regression tests directory
                //and there is no corresponding rfa or rvt, then an empty string
                //or a null will be passed into here.
                Assert.IsNotNullOrEmpty(dynamoFilePath, "Dynamo file path is invalid or missing.");
                Assert.IsNotNullOrEmpty(revitFilePath, "Revit file path is invalid or missing.");

                //open the revit model
                SwapCurrentModel(revitFilePath);

                //open the dyn file
                ViewModel.OpenCommand.Execute(dynamoFilePath);

                //run the expression and assert that it does not
                //throw an error
                Assert.DoesNotThrow(() => ViewModel.Model.RunExpression());
                var errorNodes =
                    ViewModel.Model.Nodes.Where(
                        x => x.State == ElementState.Error || x.State == ElementState.Warning);
                Assert.AreEqual(0, errorNodes.Count());
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            finally
            {
                ViewModel.Model.ShutDown(false);
                ViewModel = null;
                Teardown();
            }

            if (exception != null)
            {
                Assert.Fail(exception.Message);
            }
        }