Skip to content

Commit a929173

Browse files
committed
Changed test code to remove [DeploymentItem]
According to microsoft/testfx#295 the use of DeploymentItem tag should be reserved for special folder scenarios, and it resulted in most tests not being run on local and remote machines.
1 parent 0c18eaa commit a929173

13 files changed

+423
-83
lines changed

Xbim.Geometry.Engine.Interop.Tests/EntityRepository.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public class EntityRepository<T> : IDisposable where T : IPersistEntity
1313
public T Entity;
1414
public EntityRepository(string name, bool inRadians = false)
1515
{
16-
var path = Path.GetFullPath($@"{name}.ifc");
17-
Assert.IsTrue(File.Exists(path), path);
16+
var path = Path.GetFullPath($@"Testfiles\{name}.ifc");
17+
Assert.IsTrue(File.Exists(path), $"File not found '{path}'" );
1818
Debug.WriteLine($"Opening '{path}' for tests.");
1919
model = MemoryModel.OpenRead(path);
2020
if (inRadians)

Xbim.Geometry.Engine.Interop.Tests/Ifc4GeometryTests.cs

+52-64
Large diffs are not rendered by default.

Xbim.Geometry.Engine.Interop.Tests/IfcAdvancedBrepTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Xbim.Geometry.Engine.Interop.Tests
1111
{
1212
[TestClass]
13-
[DeploymentItem("TestFiles")]
13+
// [DeploymentItem("TestFiles")]
1414
public class IfcAdvancedBrepTests
1515
{
1616
static private IXbimGeometryEngine geomEngine;

Xbim.Geometry.Engine.Interop.Tests/IfcBooleanTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace Xbim.Geometry.Engine.Interop.Tests
1616
{
1717
[TestClass]
18-
[DeploymentItem("TestFiles")]
18+
// [DeploymentItem("TestFiles")]
1919
public class IfcBooleanTests
2020
{
2121
static private IXbimGeometryEngine geomEngine;
@@ -97,7 +97,7 @@ public void boolean_cut_failure()
9797
[TestMethod]
9898
public void SubtractionResultsInClosedWindow()
9999
{
100-
using (var model = MemoryModel.OpenRead(@"SubtractionResultsInClosedWindow.ifc"))
100+
using (var model = MemoryModel.OpenRead(@"TestFiles\SubtractionResultsInClosedWindow.ifc"))
101101
{
102102
logger.LogInformation("Running SubtractionResultsInClosedWindow");
103103
var wallBrep = model.Instances[12752] as IIfcFacetedBrep;

Xbim.Geometry.Engine.Interop.Tests/IfcCSGTests.cs

+41-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ namespace Xbim.Geometry.Engine.Interop.Tests
1818

1919
public class IfcCsgTests
2020
{
21-
22-
2321
static private IXbimGeometryEngine geomEngine;
2422
static private ILoggerFactory loggerFactory;
2523
static private ILogger logger;
@@ -174,8 +172,47 @@ public void IfcSphereTest()
174172
}
175173
}
176174

177-
175+
public static void GeneralTest(IXbimSolid solid, bool ignoreVolume = false, bool isHalfSpace = false, int entityLabel = 0)
176+
{
177+
if (ignoreVolume && !isHalfSpace && solid.Volume == 0)
178+
{
179+
Trace.WriteLine(String.Format("Entity #{0} has zero volume>", entityLabel));
180+
}
181+
if (!ignoreVolume)
182+
Assert.IsTrue(solid.Volume > 0, "Volume should be greater than 0");
183+
Assert.IsTrue(solid.SurfaceArea > 0, "Surface Area should be greater than 0");
184+
Assert.IsTrue(solid.IsValid);
185+
186+
if (!isHalfSpace)
187+
{
188+
foreach (var face in solid.Faces)
189+
{
190+
Assert.IsTrue(face.OuterBound.IsValid, "Face has no outer bound in #" + entityLabel);
191+
Assert.IsTrue(face.Area > 0, "Face area should be greater than 0 in #" + entityLabel);
192+
Assert.IsTrue(face.Perimeter > 0, "Face perimeter should be breater than 0 in #" + entityLabel);
193+
194+
if (face.IsPlanar)
195+
{
196+
Assert.IsTrue(!face.Normal.IsInvalid(), "Face normal is invalid in #" + entityLabel);
197+
// Assert.IsTrue(face.OuterBound.Edges.Count>2, "A face should have at least 3 edges");
198+
// Assert.IsTrue(!face.OuterBound.Normal.IsInvalid(), "Face outerbound normal is invalid in #" + entityLabel);
199+
// Assert.IsTrue(face.OuterBound.IsPlanar, "Face is planar but wire is not in #" + entityLabel);
200+
}
201+
else
202+
{
203+
Assert.IsFalse(face.OuterBound.IsPlanar, "Face is not planar but wire is planar in #" + entityLabel);
204+
}
205+
206+
foreach (var edge in face.OuterBound.Edges)
207+
{
208+
Assert.IsTrue(edge.EdgeGeometry.IsValid, "Edge element is invalid in #" + entityLabel);
209+
Assert.IsTrue(edge.EdgeStart.IsValid, "Edge start is invalid in #" + entityLabel);
210+
Assert.IsTrue(edge.EdgeEnd.IsValid, "Edge end is invalid in #" + entityLabel);
211+
}
212+
}
213+
}
214+
}
215+
178216

179-
180217
}
181218
}

Xbim.Geometry.Engine.Interop.Tests/IfcExtrudedAreaSolidTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Xbim.Geometry.Engine.Interop.Tests.TestFiles
1111
{
1212
[TestClass ]
13-
[DeploymentItem("TestFiles")]
13+
// [DeploymentItem("TestFiles")]
1414
public class IfcExtrudedAreaSolidTests
1515
{
1616
static private IXbimGeometryEngine geomEngine;

Xbim.Geometry.Engine.Interop.Tests/LocationAndPlacementTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ static public void Cleanup()
3636
}
3737

3838
[TestMethod]
39-
[DeploymentItem("TestFiles\\LargeTriangulatedCoordinates.ifc")]
39+
// [DeploymentItem("TestFiles\\LargeTriangulatedCoordinates.ifc")]
4040
public void LargeCoordinatesDisplacementTest()
4141
{
4242
using (var m = new MemoryModel(new Ifc2x3.EntityFactoryIfc2x3()))
4343
{
44-
m.LoadStep21("LargeTriangulatedCoordinates.ifc");
44+
m.LoadStep21("TestFiles\\LargeTriangulatedCoordinates.ifc");
4545
var c = new Xbim3DModelContext(m);
4646
c.CreateContext(null, false);
4747

Xbim.Geometry.Engine.Interop.Tests/PrimitiveGeometryTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace Xbim.Geometry.Engine.Interop.Tests
1212
{
1313
[TestClass]
14-
[DeploymentItem("TestFiles")]
14+
// [DeploymentItem("TestFiles")]
1515
public class PrimitiveGeometryTests
1616
{
1717
static private IXbimGeometryEngine geomEngine;
@@ -47,7 +47,7 @@ static public void Cleanup()
4747
[TestMethod]
4848
public void can_build_ifc_faceted_brep()
4949
{
50-
using (var model = MemoryModel.OpenRead(@"Primitives\ifc_faceted_brep.ifc"))
50+
using (var model = MemoryModel.OpenRead(@"TestFiles\Primitives\ifc_faceted_brep.ifc"))
5151
{
5252
var shape = model.Instances.OfType<IIfcFacetedBrep>().FirstOrDefault();
5353
Assert.IsNotNull(shape);
@@ -58,7 +58,7 @@ public void can_build_ifc_faceted_brep()
5858
[TestMethod]
5959
public void can_build_closed_shell()
6060
{
61-
using (var model = MemoryModel.OpenRead(@"Primitives\faulty_closed_shell.ifc"))
61+
using (var model = MemoryModel.OpenRead(@"TestFiles\Primitives\faulty_closed_shell.ifc"))
6262
{
6363
var shape = model.Instances.OfType<IIfcClosedShell>().FirstOrDefault();
6464
Assert.IsNotNull(shape);
@@ -69,7 +69,7 @@ public void can_build_closed_shell()
6969
[TestMethod]
7070
public void can_build_poorly_aligned_planar_faces()
7171
{
72-
using (var model = MemoryModel.OpenRead(@"Primitives\poor_face_planar_fidelity.ifc"))
72+
using (var model = MemoryModel.OpenRead(@"TestFiles\Primitives\poor_face_planar_fidelity.ifc"))
7373
{
7474
var shape = model.Instances.OfType<IIfcClosedShell>().FirstOrDefault();
7575
Assert.IsNotNull(shape);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using Microsoft.Extensions.Logging;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Diagnostics;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using Xbim.Ifc;
11+
using Xbim.Ifc4.Interfaces;
12+
13+
namespace Xbim.Geometry.Engine.Interop.Tests
14+
{
15+
[TestClass]
16+
public class RegressionTests
17+
{
18+
19+
static private XbimGeometryEngine geomEngine;
20+
static private ILoggerFactory loggerFactory;
21+
static private ILogger logger;
22+
23+
[ClassInitialize]
24+
static public void Initialise(TestContext context)
25+
{
26+
loggerFactory = new LoggerFactory().AddConsole(LogLevel.Trace);
27+
geomEngine = new XbimGeometryEngine();
28+
logger = loggerFactory.CreateLogger<Ifc4GeometryTests>();
29+
}
30+
[ClassCleanup]
31+
static public void Cleanup()
32+
{
33+
loggerFactory = null;
34+
geomEngine = null;
35+
logger = null;
36+
}
37+
38+
[TestMethod]
39+
// // [DeploymentItem(@"TestFiles\Regression\FailingGeom.ifc", "FailingGeom.ifc")]
40+
public void IfcHalfspace_FailingGeom()
41+
{
42+
using (var m = IfcStore.Open("TestFiles\\Regression\\FailingGeom.ifc"))
43+
{
44+
var extSolid = m.Instances.OfType<IIfcExtrudedAreaSolid>().FirstOrDefault(hs => hs.EntityLabel == 185025);
45+
var solid = geomEngine.CreateSolid(extSolid, null);
46+
IfcCsgTests.GeneralTest(solid);
47+
48+
var mlist = m.Instances.OfType<IIfcBooleanClippingResult>();
49+
foreach (var eas in mlist)
50+
{
51+
Debug.WriteLine("Todo: " + eas.EntityLabel);
52+
}
53+
54+
foreach (var eas in mlist)
55+
{
56+
// var eas = m.Instances.OfType<IIfcBooleanClippingResult>().FirstOrDefault(hs => hs.EntityLabel == 185249);
57+
Assert.IsTrue(eas != null, "No IfcBooleanClippingResult found");
58+
var ret = geomEngine.CreateSolidSet(eas, logger);
59+
60+
IfcCsgTests.GeneralTest(solid);
61+
62+
Debug.WriteLine(eas.EntityLabel + " ok");
63+
if (eas.EntityLabel == 185243)
64+
{
65+
File.WriteAllText(@"C:\Data\_tmp\185243.v5.brep", solid.ToBRep);
66+
}
67+
}
68+
}
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)