@@ -96,13 +96,25 @@ public void CreateMaterial_WithObjectProperties_SucceedsAndSetsColor()
9696 }
9797 }
9898
99- [ Test ]
100- public void AssignMaterial_ToSphere_UsingComponentPropertiesObject_Succeeds ( )
99+ private void CreateTestMaterial ( )
101100 {
102- // Ensure material exists first
103- CreateMaterial_WithObjectProperties_SucceedsAndSetsColor ( ) ;
101+ var createParams = new JObject
102+ {
103+ [ "action" ] = "create" ,
104+ [ "path" ] = _matPath ,
105+ [ "assetType" ] = "Material" ,
106+ [ "properties" ] = new JObject
107+ {
108+ [ "shader" ] = "Universal Render Pipeline/Lit" ,
109+ [ "color" ] = new JArray ( 0f , 0f , 1f , 1f )
110+ }
111+ } ;
112+ var result = ToJObject ( ManageAsset . HandleCommand ( createParams ) ) ;
113+ Assert . IsTrue ( result . Value < bool > ( "success" ) , result . Value < string > ( "error" ) ) ;
114+ }
104115
105- // Create a sphere via handler
116+ private void CreateSphere ( )
117+ {
106118 var createGo = new JObject
107119 {
108120 [ "action" ] = "create" ,
@@ -111,9 +123,18 @@ public void AssignMaterial_ToSphere_UsingComponentPropertiesObject_Succeeds()
111123 } ;
112124 var createGoResult = ToJObject ( ManageGameObject . HandleCommand ( createGo ) ) ;
113125 Assert . IsTrue ( createGoResult . Value < bool > ( "success" ) , createGoResult . Value < string > ( "error" ) ) ;
114-
115126 _sphere = GameObject . Find ( "ToolTestSphere" ) ;
116127 Assert . IsNotNull ( _sphere , "Sphere should be created." ) ;
128+ }
129+
130+ [ Test ]
131+ public void AssignMaterial_ToSphere_UsingComponentPropertiesObject_Succeeds ( )
132+ {
133+ CreateTestMaterial ( ) ;
134+ CreateSphere ( ) ;
135+
136+ // Create a sphere via handler
137+
117138
118139 // Assign material via object-typed componentProperties
119140 var modifyParams = new JObject
@@ -142,8 +163,20 @@ public void AssignMaterial_ToSphere_UsingComponentPropertiesObject_Succeeds()
142163 [ Test ]
143164 public void ReadRendererData_DoesNotInstantiateMaterial_AndIncludesSharedMaterial ( )
144165 {
145- // Prepare object and assignment
146- AssignMaterial_ToSphere_UsingComponentPropertiesObject_Succeeds ( ) ;
166+ CreateTestMaterial ( ) ;
167+ CreateSphere ( ) ;
168+ var modifyParams = new JObject
169+ {
170+ [ "action" ] = "modify" ,
171+ [ "target" ] = "ToolTestSphere" ,
172+ [ "searchMethod" ] = "by_name" ,
173+ [ "componentProperties" ] = new JObject
174+ {
175+ [ "MeshRenderer" ] = new JObject { [ "sharedMaterial" ] = _matPath }
176+ }
177+ } ;
178+ var modifyResult = ToJObject ( ManageGameObject . HandleCommand ( modifyParams ) ) ;
179+ Assert . IsTrue ( modifyResult . Value < bool > ( "success" ) , modifyResult . Value < string > ( "error" ) ) ;
147180
148181 var renderer = _sphere . GetComponent < MeshRenderer > ( ) ;
149182 int beforeId = renderer . sharedMaterial != null ? renderer . sharedMaterial . GetInstanceID ( ) : 0 ;
0 commit comments