/// <summary> /// Sets up an NUNit ResultsType object or deserializing and existing one. /// </summary> private void InitializeResults() { if (File.Exists(resultsPath)) { //read from the file var x = new XmlSerializer(typeof(resultType)); using (var sr = new StreamReader(resultsPath)) { resultsRoot = (resultType)x.Deserialize(sr); } } else { //create one result to dump everything into resultsRoot = new resultType { name = Assembly.GetExecutingAssembly().Location }; resultsRoot.testsuite = new testsuiteType { name = "DynamoTestFrameworkTests", description = "Unit tests in Revit.", time = "0.0", type = "TestFixture", result = "Success", executed = "True" }; resultsRoot.testsuite = rootSuite; resultsRoot.testsuite.results = new resultsType { Items = new object[] { } }; resultsRoot.date = DateTime.Now.ToString("yyyy-MM-dd"); resultsRoot.time = DateTime.Now.ToString("HH:mm:ss"); resultsRoot.failures = 0; resultsRoot.ignored = 0; resultsRoot.notrun = 0; resultsRoot.errors = 0; resultsRoot.skipped = 0; resultsRoot.inconclusive = 0; resultsRoot.invalid = 0; } }
//private void StartDynamo() //{ // var fecLevel = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument); // fecLevel.OfClass(typeof(Level)); // DocumentManager.Instance.CurrentUIApplication = DocumentManager.Instance.CurrentUIApplication; // //DocumentManager.Instance.CurrentUIDocument = DocumentManager.Instance.CurrentUIDocument; // dynRevitSettings.DefaultLevel = null; // BaseUnit.HostApplicationInternalAreaUnit = DynamoAreaUnit.SquareFoot; // BaseUnit.HostApplicationInternalLengthUnit = DynamoLengthUnit.DecimalFoot; // BaseUnit.HostApplicationInternalVolumeUnit = DynamoVolumeUnit.CubicFoot; // //create dynamo // var r = new Regex(@"\b(Autodesk |Structure |MEP |Architecture )\b"); // string context = r.Replace(DocumentManager.Instance.CurrentUIApplication.Application.VersionName, ""); // // create the transaction manager object // TransactionManager.SetupManager(new AutomaticTransactionStrategy()); // var dynamoController = new DynamoController_Revit(DynamoRevit.Updater, typeof(DynamoRevitViewModel), context); // DynamoController.IsTestMode = true; //} private void CalculateTotalsOnResultsRoot(resultType result) { var resultItems = result.testsuite.results.Items.ToList(); var cases = resultItems .Where(x => x.GetType() == typeof (testsuiteType)) .Cast<testsuiteType>() .SelectMany(x => x.results.Items) .Where(x => x.GetType() == typeof (testcaseType)) .Cast<testcaseType>(); var testcaseTypes = cases as testcaseType[] ?? cases.ToArray(); if (!testcaseTypes.Any()) return; result.errors = testcaseTypes.Sum(x => x.result == "Failure" ? 1 : 0); result.total = testcaseTypes.Count(); result.ignored = testcaseTypes.Sum(x => x.result == "Ignored" ? 1 : 0); result.inconclusive = testcaseTypes.Sum(x => x.result == "Inconclusive" ? 1 : 0); result.invalid = testcaseTypes.Sum(x => x.result == "Invalid" ? 1 : 0); result.notrun = testcaseTypes.Sum(x => x.executed == "NotRun" ? 1 : 0); result.skipped = testcaseTypes.Sum(x => x.result == "Skipped" ? 1 : 0); result.errors = testcaseTypes.Sum(x => x.result == "Error" ? 1 : 0); result.failures = testcaseTypes.Sum(x => x.result == "Failure" ? 1 : 0); }