Skip to content

Commit 8285ab0

Browse files
committed
new tests and changes
1 parent eeb3e9c commit 8285ab0

5 files changed

Lines changed: 216 additions & 103 deletions

File tree

test/Libraries/RevitIntegrationTests/AreaTests.cs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
using System.IO;
33
using System.Linq;
44
using Autodesk.Revit.DB;
5-
using Dynamo.Nodes;
6-
using Autodesk.DesignScript.Geometry;
7-
using CoreNodeModels.Input;
85
using NUnit.Framework;
96
using RevitServices.Persistence;
107
using RevitTestServices;
@@ -54,6 +51,37 @@ public void CanGetAreaBoundaries()
5451
AssertListOfCurves(expectedCurves, areaBoundaries);
5552
}
5653

54+
[Test]
55+
[TestModel(@".\Revision2025.rvt")]
56+
public void AreaPlanViewLvlAreaScheme()
57+
{
58+
// Arrange
59+
string samplePath = Path.Combine(workingDirectory, @".\Script\AreaPlanViewLvlAreaScheme.dyn");
60+
string testPath = Path.GetFullPath(samplePath);
61+
62+
// Act
63+
ViewModel.OpenCommand.Execute(testPath);
64+
RunCurrentModel();
65+
66+
// Assert
67+
var areaPlanView = GetFlattenedPreviewValues("024e9355feec40a189d6a44485e3b72f");
68+
Assert.AreEqual(3, areaPlanView.Count);
69+
foreach (var view in areaPlanView)
70+
{
71+
Assert.AreEqual(typeof(Revit.Elements.Views.AreaPlanView), view.GetType());
72+
Assert.IsNotNull(view);
73+
}
74+
75+
//Verify that the Area Plan Views are present in Revit as well
76+
var doc = DocumentManager.Instance.CurrentDBDocument;
77+
var allAreaPlanViewsInDoc = new FilteredElementCollector(doc)
78+
.OfClass(typeof(Autodesk.Revit.DB.View))
79+
.Cast<Autodesk.Revit.DB.View>()
80+
.Where(x => x.ViewType == ViewType.AreaPlan)
81+
.ToList();
82+
Assert.IsTrue(allAreaPlanViewsInDoc.Any(), "No Area Plan Views found in the document.");
83+
}
84+
5785
private static void AssertListOfCurves(List<Autodesk.DesignScript.Geometry.Curve> expectedCurves, List<object> areaBoundaries)
5886
{
5987
Assert.AreEqual(expectedCurves.Count(), areaBoundaries.Count());
@@ -74,8 +102,8 @@ private static void AssertListOfCurves(List<Autodesk.DesignScript.Geometry.Curve
74102
Assert.AreEqual(expectedEndPoint.X, actualEndPoint.X, Tolerance);
75103
Assert.AreEqual(expectedEndPoint.Y, actualEndPoint.Y, Tolerance);
76104
Assert.AreEqual(expectedEndPoint.Z, actualEndPoint.Z, Tolerance);
77-
78105
}
79106
}
107+
80108
}
81109
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using System.IO;
2+
using System.Linq;
3+
using NUnit.Framework;
4+
using RevitTestServices;
5+
using RTF.Framework;
6+
7+
namespace RevitSystemTests
8+
{
9+
[TestFixture]
10+
public class FloorTests : RevitSystemTestBase
11+
{
12+
[Test]
13+
[TestModel(@".\DifferentTypeRooms.rvt")]
14+
public void FloorNodes()
15+
{
16+
string samplePath = Path.Combine(workingDirectory, @".\Script\FloorNodes.dyn");
17+
string testPath = Path.GetFullPath(samplePath);
18+
19+
ViewModel.OpenCommand.Execute(testPath);
20+
RunCurrentModel();
21+
22+
var floorTypeName = GetPreviewValue("810634a9a60f41a2ab24833354eb6f54");
23+
Assert.AreEqual("Standard", floorTypeName);
24+
25+
var floorTypeByName = GetPreviewValue("a450f0ac27ea4802902459aa1e2b374b");
26+
Assert.AreEqual("FloorTest", floorTypeByName.ToString());
27+
28+
var categoryName = GetPreviewValue("de31ecaf910a407bb9d94fd8fe9c67a2");
29+
Assert.AreEqual("Floors", categoryName);
30+
31+
var floorPlanView = GetPreviewValue("8fbbb68682a2473e9289ee30c476cfe6");
32+
var expectedValue = "FloorPlanView(Name = Level 0(1) )";
33+
Assert.AreEqual(expectedValue, floorPlanView.ToString());
34+
}
35+
36+
[Test]
37+
[TestModel(@".\DifferentTypeRooms.rvt")]
38+
public void FloorPointsAddMove()
39+
{
40+
string samplePath = Path.Combine(workingDirectory, @".\Script\FloorPointsAddMove.dyn");
41+
string testPath = Path.GetFullPath(samplePath);
42+
43+
ViewModel.OpenCommand.Execute(testPath);
44+
AssertNoDummyNodes();
45+
RunCurrentModel();
46+
47+
//On the first run of the script, only the added point will be read
48+
//Assert that the new node was added
49+
var floorPoints1Node = AllNodes
50+
.FirstOrDefault(n => n.Name == "Floor.Points1");
51+
var floorPoints1 = GetFlattenedPreviewValues(floorPoints1Node.GUID.ToString("N"));
52+
Assert.AreEqual(1, floorPoints1.Count);
53+
var pointAddedExceptedValue = "Point(X = 1000.000, Y = 0.000, Z = 0.000)";
54+
Assert.AreEqual(pointAddedExceptedValue, floorPoints1[0].ToString());
55+
56+
57+
var indexFloorPoints = AllNodes
58+
.OfType<CoreNodeModels.Input.DoubleInput>()
59+
.FirstOrDefault(n => n.Name == "IndexFloorPoints");
60+
indexFloorPoints.Value = "4.0";
61+
62+
var movePoint = AllNodes
63+
.OfType<CoreNodeModels.Input.DoubleInput>()
64+
.FirstOrDefault(n => n.Name == "MovePoint");
65+
movePoint.Value = "8.0";
66+
67+
//!!For some reason, double run in code for this script doesn't work as expected
68+
//The Floor.Points remains at 1 point so in order to make it work, we save as the script, close it and open the new one
69+
//Manually, if we do double run, it works fine
70+
string tempPath = Path.Combine(workingDirectory, "newScript.dyn");
71+
ViewModel.SaveAsCommand.Execute(tempPath);
72+
73+
ViewModel.CloseHomeWorkspaceCommand.Execute(null);
74+
ViewModel.OpenCommand.Execute(tempPath);
75+
76+
//Now we rerun the script, the new point will be moved on Z axis,
77+
//and the 4 points of the floor will be read and will appear in the canvas
78+
RunCurrentModel();
79+
80+
floorPoints1Node = AllNodes
81+
.FirstOrDefault(n => n.Name == "Floor.Points1");
82+
floorPoints1 = GetFlattenedPreviewValues(floorPoints1Node.GUID.ToString("N"));
83+
Assert.AreEqual(5, floorPoints1.Count);
84+
85+
86+
//Verify the moved point
87+
var floorPoints2Node = AllNodes
88+
.FirstOrDefault(n => n.Name == "Floor.Points2");
89+
var floorPoints2 = GetFlattenedPreviewValues(floorPoints2Node.GUID.ToString("N"));
90+
Assert.AreEqual(5, floorPoints2.Count);
91+
var pointMovedExceptedValue = "Point(X = 1000.000, Y = 0.000, Z = 2438.400)";
92+
Assert.AreEqual(pointMovedExceptedValue, floorPoints2[4].ToString());
93+
}
94+
}
95+
}

test/Libraries/RevitIntegrationTests/FloorTypeTests.cs

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -103,89 +103,5 @@ public void CanCheckIfFloorTypeIsFoundationSlab()
103103
var isFoundationSlabAfterChange = GetPreviewValue("4b5c27789bab4c43a6864e33786a2847");
104104
Assert.AreEqual(true, isFoundationSlabAfterChange);
105105
}
106-
107-
108-
[Test]
109-
[TestModel(@".\DifferentTypeRooms.rvt")]
110-
public void FloorNodes()
111-
{
112-
string samplePath = Path.Combine(workingDirectory, @".\Script\FloorNodes.dyn");
113-
string testPath = Path.GetFullPath(samplePath);
114-
115-
ViewModel.OpenCommand.Execute(testPath);
116-
RunCurrentModel();
117-
118-
var floorTypeName = GetPreviewValue("810634a9a60f41a2ab24833354eb6f54");
119-
Assert.AreEqual("Standard", floorTypeName);
120-
121-
var floorTypeByName = GetPreviewValue("a450f0ac27ea4802902459aa1e2b374b");
122-
Assert.AreEqual("FloorTest", floorTypeByName.ToString());
123-
124-
var categoryName = GetPreviewValue("de31ecaf910a407bb9d94fd8fe9c67a2");
125-
Assert.AreEqual("Floors", categoryName);
126-
127-
var floorPlanView = GetPreviewValue("8fbbb68682a2473e9289ee30c476cfe6");
128-
var expectedValue = "FloorPlanView(Name = Level 0(1) )";
129-
Assert.AreEqual(expectedValue, floorPlanView.ToString());
130-
}
131-
132-
[Test]
133-
[TestModel(@".\DifferentTypeRooms.rvt")]
134-
public void FloorPointsAddMove()
135-
{
136-
string samplePath = Path.Combine(workingDirectory, @".\Script\FloorPointsAddMove.dyn");
137-
string testPath = Path.GetFullPath(samplePath);
138-
139-
ViewModel.OpenCommand.Execute(testPath);
140-
AssertNoDummyNodes();
141-
RunCurrentModel();
142-
143-
//On the first run of the script, only the added point will be read
144-
//Assert that the new node was added
145-
var floorPoints1Node = AllNodes
146-
.FirstOrDefault(n => n.Name == "Floor.Points1");
147-
var floorPoints1 = GetFlattenedPreviewValues(floorPoints1Node.GUID.ToString("N"));
148-
Assert.AreEqual(1, floorPoints1.Count);
149-
var pointAddedExceptedValue = "Point(X = 1000.000, Y = 0.000, Z = 0.000)";
150-
Assert.AreEqual(pointAddedExceptedValue, floorPoints1[0].ToString());
151-
152-
153-
var indexFloorPoints = AllNodes
154-
.OfType<CoreNodeModels.Input.DoubleInput>()
155-
.FirstOrDefault(n => n.Name == "IndexFloorPoints");
156-
indexFloorPoints.Value = "4.0";
157-
158-
var movePoint = AllNodes
159-
.OfType<CoreNodeModels.Input.DoubleInput>()
160-
.FirstOrDefault(n => n.Name == "MovePoint");
161-
movePoint.Value = "8.0";
162-
163-
//!!For some reason, double run in code for this script doesn't work as expected
164-
//The Floor.Points remains at 1 point so in order to make it work, we save as the script, close it and open the new one
165-
//Manually, if we do double run, it works fine
166-
string tempPath = Path.Combine(workingDirectory, "newScript.dyn");
167-
ViewModel.SaveAsCommand.Execute(tempPath);
168-
169-
ViewModel.CloseHomeWorkspaceCommand.Execute(null);
170-
ViewModel.OpenCommand.Execute(tempPath);
171-
172-
//Now we rerun the script, the new point will be moved on Z axis,
173-
//and the 4 points of the floor will be read and will appear in the canvas
174-
RunCurrentModel();
175-
176-
floorPoints1Node = AllNodes
177-
.FirstOrDefault(n => n.Name == "Floor.Points1");
178-
floorPoints1 = GetFlattenedPreviewValues(floorPoints1Node.GUID.ToString("N"));
179-
Assert.AreEqual(5, floorPoints1.Count);
180-
181-
182-
//Verify the moved point
183-
var floorPoints2Node = AllNodes
184-
.FirstOrDefault(n => n.Name == "Floor.Points2");
185-
var floorPoints2 = GetFlattenedPreviewValues(floorPoints2Node.GUID.ToString("N"));
186-
Assert.AreEqual(5, floorPoints2.Count);
187-
var pointMovedExceptedValue = "Point(X = 1000.000, Y = 0.000, Z = 2438.400)";
188-
Assert.AreEqual(pointMovedExceptedValue, floorPoints2[4].ToString());
189-
}
190106
}
191107
}

test/Libraries/RevitIntegrationTests/RoofTests.cs

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.IO;
1+
using System.IO;
72
using NUnit.Framework;
83
using RTF.Framework;
94
using RevitTestServices;
5+
using Dynamo.Graph.Nodes.ZeroTouch;
6+
using System.Linq;
107

118
namespace RevitSystemTests
129
{
@@ -26,7 +23,7 @@ public void ByOutlineExtrusionTypeAndLevel()
2623

2724

2825
var type = GetPreviewValue("9daa9b583bdf4659901779b540fdeecc");
29-
Assert.AreEqual(type.GetType(), typeof(Revit.Elements.Roof));
26+
Assert.AreEqual(typeof(Revit.Elements.Roof), type.GetType());
3027
}
3128

3229
[Test]
@@ -42,7 +39,69 @@ public void ByOutlineTypeAndLevel()
4239

4340

4441
var type = GetPreviewValue("c6d16ef7c551467a8d46cd307b2a465b");
45-
Assert.AreEqual(type.GetType(), typeof(Revit.Elements.Roof));
42+
Assert.AreEqual(typeof(Revit.Elements.Roof), type.GetType());
43+
}
44+
45+
[Test]
46+
[TestModel(@".\DifferentTypeRooms.rvt")]
47+
public void RoofAddAndMovePoint()
48+
{
49+
string samplePath = Path.Combine(workingDirectory, @".\Script\RoofAddAndMovePoint.dyn");
50+
string testPath = Path.GetFullPath(samplePath);
51+
52+
ViewModel.OpenCommand.Execute(testPath);
53+
AssertNoDummyNodes();
54+
RunCurrentModel();
55+
56+
var roofByOutline = GetFlattenedPreviewValues("58315d46b9934fafb62bceaca05b2255");
57+
Assert.AreEqual(typeof(Revit.Elements.Roof), roofByOutline[0].GetType());
58+
59+
var roofPoints1 = AllNodes
60+
.FirstOrDefault(n => n.Name == "roof.Points1");
61+
62+
//var roofPoints1 = "0a224bb8655743fcbb6fb5c1e002bbf0";
63+
64+
var roofByOutlineNode = GetNode<DSFunction>("58315d46-b993-4faf-b62b-ceaca05b2255");
65+
var roofPoints1Node = GetNode<DSFunction>("0a224bb8-6557-43fc-bb6f-b5c1e002bbf0");
66+
67+
//Connect the output of Roof.ByOutlineTypeAndLevel node to the input of Roof.Points1 node
68+
MakeConnector(roofByOutlineNode, roofPoints1Node, 0, 0);
69+
RunCurrentModel();
70+
71+
var roofPoints1Value = GetFlattenedPreviewValues(roofPoints1Node.GUID.ToString("N"));
72+
Assert.AreEqual(7, roofPoints1Value.Count);
73+
var roofPoints1ExpectedValue = "Point(X = -9976.661, Y = -7119.928, Z = 4350.500)";
74+
Assert.AreEqual(roofPoints1ExpectedValue, roofPoints1Value[0].ToString());
75+
76+
var roofPoints2 = AllNodes
77+
.FirstOrDefault(n => n.Name == "roof.Points2");
78+
var roofPoints2Node = GetNode<DSFunction>("198154aa-94e4-4857-aa4c-6980dd1eef98");
79+
80+
//Connect the output of Roof.ByOutlineTypeAndLevel node to the input of Roof.Points2 node
81+
MakeConnector(roofByOutlineNode, roofPoints2Node, 0, 0);
82+
RunCurrentModel();
83+
84+
var roofPoints2Value = GetFlattenedPreviewValues(roofPoints2Node.GUID.ToString("N"));
85+
Assert.AreEqual(7, roofPoints2Value.Count);
86+
var roofPoints2ExpectedValue = "Point(X = -9976.661, Y = -7119.928, Z = 4960.100)";
87+
Assert.AreEqual(roofPoints2ExpectedValue, roofPoints2Value[0].ToString());
88+
}
89+
90+
[Test]
91+
[TestModel(@".\Revision2025.rvt")]
92+
public void RoofByOutlineExtrusionTypeAndLevel()
93+
{
94+
string samplePath = Path.Combine(workingDirectory, @".\Script\RoofByOutlineExtrusionTypeAndLevel.dyn");
95+
string testPath = Path.GetFullPath(samplePath);
96+
97+
ViewModel.OpenCommand.Execute(testPath);
98+
RunCurrentModel();
99+
100+
var roofByOutline = GetPreviewValue("541167eee9a9407faf6e036fecbc61c0");
101+
Assert.AreEqual(typeof(Revit.Elements.Roof), roofByOutline.GetType());
102+
103+
var roofTypeName = GetPreviewValue("495506b35585413389c1486863480f32");
104+
Assert.AreEqual("Roof_Generic-400mm", roofTypeName);
46105
}
47106
}
48107
}

test/Libraries/RevitIntegrationTests/StructuralFramingTests.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
using System;
2+
using System.IO;
23
using System.Linq;
3-
44
using Autodesk.Revit.DB;
5-
65
using DSRevitNodesUI;
7-
86
using NUnit.Framework;
9-
107
using RevitServices.Persistence;
11-
128
using RevitTestServices;
13-
149
using RTF.Framework;
15-
1610
using FamilyType = Revit.Elements.FamilyType;
1711
using IntegerSlider = CoreNodeModels.Input.IntegerSlider;
1812

@@ -80,6 +74,27 @@ private void AssertTypeAndCountWhenSelectingFromDropDown(int selectedIndex)
8074
Assert.AreEqual(fec.ToElements().Count, slider.Value);
8175
}
8276

77+
[Test]
78+
[TestModel(@".\LOC model_2022_automatic test.rvt")]
79+
public void LocationStructFram_StrucPlanView()
80+
{
81+
string samplePath = Path.Combine(workingDirectory, @".\Script\LocationStructFram_StrucPlanView.dyn");
82+
string testPath = Path.GetFullPath(samplePath);
83+
84+
ViewModel.OpenCommand.Execute(testPath);
85+
RunCurrentModel();
86+
87+
var structFramLoc = GetPreviewValue("b16048797c57445f90ae241ff895eb2f");
88+
var expectedLocation = "Line(StartPoint = Point(X = -19127.681, Y = 13470.534, Z = 5994.798), " +
89+
"EndPoint = Point(X = -15127.681, Y = 13470.534, Z = 5994.798), " +
90+
"Direction = Vector(X = 4000.000, Y = -0.000, Z = 0.000, Length = 4000.000))";
91+
Assert.AreEqual(expectedLocation, structFramLoc.ToString());
92+
93+
var structFramPlanView = GetPreviewValue("064eb4a3ad6944a9b316d5020ad31145");
94+
var expectedPlanView = "StructuralPlanView(Name = Level 1(1) )";
95+
Assert.AreEqual(expectedPlanView, structFramPlanView.ToString());
96+
}
97+
8398
private void CompareSliderCountAndMemberCount(BuiltInCategory cat, int sliderCount)
8499
{
85100
var slider = ViewModel.Model.CurrentWorkspace.Nodes.FirstOrDefault(x => x is IntegerSlider) as IntegerSlider;

0 commit comments

Comments
 (0)