@@ -182,5 +182,56 @@ public void SkinnedMeshTest()
182
182
// In the future we'll want to assert the opposite!
183
183
Assert . That ( cubeInstance . GetComponentsInChildren < SkinnedMeshRenderer > ( ) , Is . Empty ) ;
184
184
}
185
+
186
+ [ Test ]
187
+ public void MapNameToSourceTest ( )
188
+ {
189
+ //Create a cube with 3 children game objects
190
+ var cube = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
191
+ var capsule = GameObject . CreatePrimitive ( PrimitiveType . Capsule ) ;
192
+ var sphere = GameObject . CreatePrimitive ( PrimitiveType . Sphere ) ;
193
+ var quad = GameObject . CreatePrimitive ( PrimitiveType . Quad ) ;
194
+
195
+ capsule . transform . parent = cube . transform ;
196
+ sphere . transform . parent = cube . transform ;
197
+ quad . transform . parent = cube . transform ;
198
+ capsule . transform . SetSiblingIndex ( 0 ) ;
199
+
200
+ //Create a similar Heirarchy that we can use as our phony "exported" hierarchy.
201
+ var cube2 = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
202
+ var capsule2 = GameObject . CreatePrimitive ( PrimitiveType . Capsule ) ;
203
+ var sphere2 = GameObject . CreatePrimitive ( PrimitiveType . Sphere ) ;
204
+ var quad2 = GameObject . CreatePrimitive ( PrimitiveType . Quad ) ;
205
+
206
+ capsule2 . transform . parent = cube2 . transform ;
207
+ sphere2 . transform . parent = cube2 . transform ;
208
+ quad2 . transform . parent = cube2 . transform ;
209
+ capsule . transform . SetSiblingIndex ( 1 ) ;
210
+
211
+ var dictionary = ConvertToModel . MapNameToSourceRecursive ( cube , cube2 ) ;
212
+
213
+ //We expect these to pass because we've given it an identical game object, as it would have after a normal export.
214
+ Assert . AreSame ( capsule2 , dictionary [ capsule . name ] ) ;
215
+ Assert . AreSame ( sphere2 , dictionary [ sphere . name ] ) ;
216
+ Assert . AreSame ( quad2 , dictionary [ quad . name ] ) ;
217
+ Assert . True ( dictionary . Count == 4 ) ;
218
+
219
+ //Create a broken hierarchy, one that is missing a primitive
220
+ var cube3 = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
221
+ var capsule3 = GameObject . CreatePrimitive ( PrimitiveType . Capsule ) ;
222
+ var sphere3 = GameObject . CreatePrimitive ( PrimitiveType . Sphere ) ;
223
+
224
+ capsule3 . transform . parent = cube3 . transform ;
225
+ sphere3 . transform . parent = cube3 . transform ;
226
+
227
+ var dictionaryBroken = ConvertToModel . MapNameToSourceRecursive ( cube , cube3 ) ;
228
+
229
+ //the dictionary size should be equal to the amount of children + the parent
230
+ Assert . True ( dictionaryBroken . Count == 4 ) ;
231
+
232
+ Assert . IsNull ( dictionaryBroken [ quad . name ] ) ;
233
+ Assert . AreSame ( capsule3 , dictionaryBroken [ capsule . name ] ) ;
234
+ Assert . AreSame ( sphere3 , dictionaryBroken [ sphere . name ] ) ;
235
+ }
185
236
}
186
237
}
0 commit comments