1616using System . Threading . Tasks ;
1717using FirebaseAdmin ;
1818using Google . Apis . Auth . OAuth2 ;
19+ using Google . Apis . Http ;
1920using Xunit ;
2021
2122namespace FirebaseAdmin . Tests
@@ -93,6 +94,7 @@ public void CreateAppOptions()
9394 Credential = credential ,
9495 ProjectId = "test-project" ,
9596 ServiceAccountId = "[email protected] " , 97+ HttpClientFactory = new MockHttpClientFactory ( new MockMessageHandler ( ) ) ,
9698 } ;
9799 var app = FirebaseApp . Create ( options ) ;
98100 Assert . Equal ( "[DEFAULT]" , app . Name ) ;
@@ -102,6 +104,42 @@ public void CreateAppOptions()
102104 Assert . Same ( credential , copy . Credential ) ;
103105 Assert . Equal ( "test-project" , copy . ProjectId ) ;
104106 Assert . Equal ( "[email protected] " , copy . ServiceAccountId ) ; 107+ Assert . Same ( typeof ( MockHttpClientFactory ) , copy . HttpClientFactory . GetType ( ) ) ;
108+ }
109+
110+ [ Fact ]
111+ public void CreateAppOptionsNoClientFactory ( )
112+ {
113+ var credential = GoogleCredential . FromAccessToken ( "token" ) ;
114+ var options = new AppOptions ( )
115+ {
116+ Credential = credential ,
117+ ProjectId = "test-project" ,
118+ ServiceAccountId = "[email protected] " , 119+ } ;
120+ var app = FirebaseApp . Create ( options ) ;
121+ Assert . Equal ( "[DEFAULT]" , app . Name ) ;
122+
123+ var copy = app . Options ;
124+ Assert . NotSame ( options , copy ) ;
125+ Assert . Same ( credential , copy . Credential ) ;
126+ Assert . Equal ( "test-project" , copy . ProjectId ) ;
127+ Assert . Equal ( "[email protected] " , copy . ServiceAccountId ) ; 128+ Assert . Same ( typeof ( HttpClientFactory ) , copy . HttpClientFactory . GetType ( ) ) ;
129+ }
130+
131+ [ Fact ]
132+ public void NoHttpClientFactory ( )
133+ {
134+ var credential = GoogleCredential . FromAccessToken ( "token" ) ;
135+ var options = new AppOptions ( )
136+ {
137+ Credential = credential ,
138+ ProjectId = "test-project" ,
139+ ServiceAccountId = "[email protected] " , 140+ HttpClientFactory = null ,
141+ } ;
142+ Assert . Throws < ArgumentNullException > ( ( ) => FirebaseApp . Create ( options ) ) ;
105143 }
106144
107145 [ Fact ]
0 commit comments