-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathCollapseVerticesTests.cs
More file actions
54 lines (45 loc) · 1.63 KB
/
CollapseVerticesTests.cs
File metadata and controls
54 lines (45 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using NUnit.Framework;
using UnityEngine;
using UnityEngine.ProBuilder;
using UnityEngine.ProBuilder.MeshOperations;
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
#if UNITY_EDITOR && PB_CREATE_TEST_MESH_TEMPLATES
using UnityEngine.ProBuilder.Tests.Framework;
#endif
static class CollapseVerticesTests
{
[Test]
public static void CollapseToFirst_MatchesTemplate()
{
var cube = ShapeFactory.Instantiate<Cube>();
var res = cube.MergeVertices(new[] { 0, 1 }, true);
Assert.AreEqual(3, res);
cube.ToMesh();
cube.Refresh();
#if UNITY_EDITOR && PB_CREATE_TEST_MESH_TEMPLATES
TestUtility.SaveAssetTemplate(cube.mesh, cube.name);
#endif
RuntimeUtility.AssertMeshAttributesValid(cube.mesh);
var template = Resources.Load<Mesh>(RuntimeUtility.GetResourcesPath<Mesh>(cube.name));
Assert.IsNotNull(template);
RuntimeUtility.AssertAreEqual(template, cube.mesh);
Object.DestroyImmediate(cube);
}
[Test]
public static void CollapseToCenter_MatchesTemplate()
{
var cube = ShapeFactory.Instantiate<Cube>();
cube.MergeVertices(new[] { 0, 1 });
cube.ToMesh();
cube.Refresh();
#if UNITY_EDITOR && PB_CREATE_TEST_MESH_TEMPLATES
TestUtility.SaveAssetTemplate(cube.mesh, cube.name);
#endif
RuntimeUtility.AssertMeshAttributesValid(cube.mesh);
var template = Resources.Load<Mesh>(RuntimeUtility.GetResourcesPath<Mesh>(cube.name));
Assert.IsNotNull(template);
RuntimeUtility.AssertAreEqual(template, cube.mesh);
UnityEngine.Object.DestroyImmediate(cube);
}
}