@@ -31,18 +31,11 @@ private class Friend : ParseObject { }
3131 [ TestInitialize ]
3232 public void SetUp ( )
3333 {
34- // Initialize the client and ensure the instance is set
35- Client = new ParseClient ( new ServerConnectionData { Test = true } ) ;
36- Client . Publicize ( ) ;
37-
38- // Register the test classes
39- Client . RegisterSubclass ( typeof ( TestObject ) ) ;
40- Client . RegisterSubclass ( typeof ( Friend ) ) ;
41- Client . RegisterSubclass ( typeof ( ParseUser ) ) ;
42- Client . RegisterSubclass ( typeof ( ParseSession ) ) ;
43- Client . RegisterSubclass ( typeof ( ParseUser ) ) ;
44-
4534 // **--- Mocking Setup ---**
35+ // Build a service hub with mocked controllers so the tests never make real
36+ // network requests (previously the mock hub was created but never wired into
37+ // the client, so calls such as SignUpAsync hit the dead https://api.parse.com
38+ // default server and failed on the CI runner).
4639 var hub = new MutableServiceHub ( ) ; // Use MutableServiceHub for mocking
4740 var mockUserController = new Mock < IParseUserController > ( ) ;
4841 var mockObjectController = new Mock < IParseObjectController > ( ) ;
@@ -52,7 +45,7 @@ public void SetUp()
5245 . Setup ( controller => controller . SignUpAsync (
5346 It . IsAny < IObjectState > ( ) ,
5447 It . IsAny < IDictionary < string , IParseFieldOperation > > ( ) ,
55- It . IsAny < IServiceHub > ( ) ,
48+ It . IsAny < IServiceHub > ( ) ,
5649 It . IsAny < CancellationToken > ( ) ) )
5750 . ReturnsAsync ( new MutableObjectState { ObjectId = "some0neTol4v4" } ) ; // Predefined ObjectId for User
5851
@@ -74,10 +67,19 @@ public void SetUp()
7467 hub . UserController = mockUserController . Object ;
7568 hub . ObjectController = mockObjectController . Object ;
7669
70+ // Initialize the client with the mocked hub and ensure the instance is set.
71+ Client = new ParseClient ( new ServerConnectionData { Test = true } , hub ) ;
72+ Client . Publicize ( ) ;
73+
74+ // Register the test classes
75+ Client . RegisterSubclass ( typeof ( TestObject ) ) ;
76+ Client . RegisterSubclass ( typeof ( Friend ) ) ;
77+ Client . RegisterSubclass ( typeof ( ParseUser ) ) ;
78+ Client . RegisterSubclass ( typeof ( ParseSession ) ) ;
7779 }
78-
80+
7981 [ TestCleanup ]
80- public void TearDown ( ) => ( Client . Services as ServiceHub ) . Reset ( ) ;
82+ public void TearDown ( ) => ( Client . Services as ServiceHub ?? ( Client . Services as OrchestrationServiceHub ) ? . Default as ServiceHub ) ? . Reset ( ) ;
8183
8284 [ TestMethod ]
8385 public void TestRelationQuery ( )
0 commit comments