@@ -15,7 +15,6 @@ namespace Contentstack.Management.Core.Tests.IntegrationTest
1515 public class Contentstack001_LoginTest
1616 {
1717 private readonly IConfigurationRoot _configuration = new ConfigurationBuilder ( ) . AddJsonFile ( "appsettings.json" ) . Build ( ) ;
18-
1918 [ TestMethod ]
2019 [ DoNotParallelize ]
2120 public void Test001_Should_Return_Failuer_On_Wrong_Login_Credentials ( )
@@ -60,42 +59,34 @@ public void Test002_Should_Return_Failuer_On_Wrong_Async_Login_Credentials()
6059
6160 [ TestMethod ]
6261 [ DoNotParallelize ]
63- public void Test003_Should_Return_Success_On_Async_Login ( )
62+ public async System . Threading . Tasks . Task Test003_Should_Return_Success_On_Async_Login ( )
6463 {
6564 ContentstackClient client = new ContentstackClient ( ) ;
66- var response = client . LoginAsync ( Contentstack . Credential ) ;
67-
68- response . ContinueWith ( ( t ) =>
65+
66+ try
6967 {
70- if ( t . IsCompleted )
71- {
72- try
73- {
74- ContentstackResponse contentstackResponse = t . Result ;
75- string loginResponse = contentstackResponse . OpenResponse ( ) ;
76-
77- Assert . IsNotNull ( client . contentstackOptions . Authtoken ) ;
78- Assert . IsNotNull ( loginResponse ) ;
79- } catch ( Exception e )
80- {
81- Assert . Fail ( e . Message ) ;
82- }
68+ ContentstackResponse contentstackResponse = await client . LoginAsync ( Contentstack . Credential ) ;
69+ string loginResponse = contentstackResponse . OpenResponse ( ) ;
8370
84- }
85- } ) ;
86- Thread . Sleep ( 3000 ) ;
71+ Assert . IsNotNull ( client . contentstackOptions . Authtoken ) ;
72+ Assert . IsNotNull ( loginResponse ) ;
73+
74+ await client . LogoutAsync ( ) ;
75+ }
76+ catch ( Exception e )
77+ {
78+ Assert . Fail ( e . Message ) ;
79+ }
8780 }
8881
8982 [ TestMethod ]
9083 [ DoNotParallelize ]
9184 public void Test004_Should_Return_Success_On_Login ( )
9285 {
93- string email = _configuration . GetSection ( "Contentstack:Credentials:Email" ) . Value ;
94- string password = _configuration . GetSection ( "Contentstack:Credentials:Password" ) . Value ;
95-
9686 try
9787 {
98- ContentstackClient client = Contentstack . Client ;
88+ ContentstackClient client = new ContentstackClient ( ) ;
89+
9990 ContentstackResponse contentstackResponse = client . Login ( Contentstack . Credential ) ;
10091 string loginResponse = contentstackResponse . OpenResponse ( ) ;
10192
@@ -114,7 +105,10 @@ public void Test005_Should_Return_Loggedin_User()
114105 {
115106 try
116107 {
117- ContentstackClient client = Contentstack . Client ;
108+ ContentstackClient client = new ContentstackClient ( ) ;
109+
110+ client . Login ( Contentstack . Credential ) ;
111+
118112 ContentstackResponse response = client . GetUser ( ) ;
119113
120114 var user = response . OpenJObjectResponse ( ) ;
@@ -134,7 +128,10 @@ public async System.Threading.Tasks.Task Test006_Should_Return_Loggedin_User_Asy
134128 {
135129 try
136130 {
137- ContentstackClient client = Contentstack . Client ;
131+ ContentstackClient client = new ContentstackClient ( ) ;
132+
133+ await client . LoginAsync ( Contentstack . Credential ) ;
134+
138135 ContentstackResponse response = await client . GetUserAsync ( ) ;
139136
140137 var user = response . OpenJObjectResponse ( ) ;
@@ -160,7 +157,10 @@ public void Test007_Should_Return_Loggedin_User_With_Organizations_detail()
160157 ParameterCollection collection = new ParameterCollection ( ) ;
161158 collection . Add ( "include_orgs_roles" , true ) ;
162159
163- ContentstackClient client = Contentstack . Client ;
160+ ContentstackClient client = new ContentstackClient ( ) ;
161+
162+ client . Login ( Contentstack . Credential ) ;
163+
164164 ContentstackResponse response = client . GetUser ( collection ) ;
165165
166166 var user = response . OpenJObjectResponse ( ) ;
0 commit comments