22using Contentstack . Core ;
33using Contentstack . Core . Models ;
44using System . Configuration ;
5+ using Microsoft . Extensions . Options ;
56
67namespace Contentstack . Core . Tests
78{
@@ -17,6 +18,30 @@ System.Configuration.Configuration assemblyConfiguration
1718 }
1819 }
1920
21+ public static ContentstackClient GetSyncStack ( )
22+ {
23+ StackConfig config = new StackConfig ( ) ;
24+ if ( config . assemblyConfiguration . HasFile && string . Compare ( config . assemblyConfiguration . FilePath , config . currentConfiguration . FilePath , true ) != 0 )
25+ {
26+ config . assemblyConfiguration . SaveAs ( config . currentConfiguration . FilePath ) ;
27+ ConfigurationManager . RefreshSection ( "appSettings" ) ;
28+ ConfigurationManager . RefreshSection ( "connectionStrings" ) ;
29+ }
30+ string apiKey = ConfigurationManager . AppSettings [ "sync_api_key" ] ;
31+ string accessToken = ConfigurationManager . AppSettings [ "sync_access_token" ] ;
32+ string environment = ConfigurationManager . AppSettings [ "sync_environment" ] ;
33+ string host = ConfigurationManager . AppSettings [ "host" ] ;
34+ Configuration . ContentstackOptions contentstackOptions = new Configuration . ContentstackOptions
35+ {
36+ ApiKey = apiKey ,
37+ AccessToken = accessToken ,
38+ Environment = environment ,
39+ Host = host
40+ } ;
41+
42+ ContentstackClient contentstackClient = new ContentstackClient ( new OptionsWrapper < Configuration . ContentstackOptions > ( contentstackOptions ) ) ;
43+ return contentstackClient ;
44+ }
2045
2146 public static ContentstackClient GetStack ( )
2247 {
@@ -30,16 +55,16 @@ public static ContentstackClient GetStack()
3055 string apiKey = ConfigurationManager . AppSettings [ "api_key" ] ;
3156 string accessToken = ConfigurationManager . AppSettings [ "access_token" ] ;
3257 string environment = ConfigurationManager . AppSettings [ "environment" ] ;
33-
58+ string host = ConfigurationManager . AppSettings [ "host" ] ;
3459 Configuration . ContentstackOptions contentstackOptions = new Configuration . ContentstackOptions
3560 {
3661 ApiKey = apiKey ,
3762 AccessToken = accessToken ,
38- Environment = environment
63+ Environment = environment ,
64+ Host = host
3965 } ;
4066
41- ContentstackClient contentstackClient = new ContentstackClient ( apiKey , accessToken , environment ) ;
42-
67+ ContentstackClient contentstackClient = new ContentstackClient ( new OptionsWrapper < Configuration . ContentstackOptions > ( contentstackOptions ) ) ;
4368 return contentstackClient ;
4469
4570 }
0 commit comments