// Happy path /wo retry option public async Task WhenApiKeyIsValid_CreatesRequestToken() { //Act CreateRequestTokenResult result = await _client.CreateRequestToken(); RequestToken token = JsonConvert.DeserializeObject <RequestToken>(result.Json); //Assert Assert.True(result.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.True(token.Success); Assert.False(string.IsNullOrWhiteSpace(token.Token)); }
public async Task WhenApiKeyIsInvalidAndCalledMultipleTimes_DoesNotBreakAndGivesErrorCode() { //Arrange var client = new TmdbNetworkClient(null, "invalidkeytest1012"); //Act CreateRequestTokenResult result = await client.CreateRequestToken(3, 1000); //Assert Assert.True(result.HttpStatusCode == System.Net.HttpStatusCode.Unauthorized); }
// Setup steps: // -(1) set up a new unused request token // -(2) Validate the request token // -(3) Create a new session public async Task InitializeAsync() { var tokenResponse = await _client.CreateRequestToken(); var token = JsonConvert.DeserializeObject <RequestToken>(tokenResponse.Json); await _client.ValidateRequestTokenWithLogin (_settings.AccountName, _settings.Password, token.Token); var createSessionIdResult = await _client.CreateSessionId(token.Token); SessionId = JsonConvert.DeserializeObject <SessionIdResponseModel>(createSessionIdResult.Json).SessionId; }
public async Task InitializeAsync() { _output.WriteLine("Creating request token: "); var createRequestTokenResult = await _client.CreateRequestToken(); _output.WriteLine($"Server response: {createRequestTokenResult.HttpStatusCode}"); var token = JsonConvert.DeserializeObject <RequestToken>(createRequestTokenResult.Json); _output.WriteLine("Request token validation: "); var validateTokenResult = await _client.ValidateRequestTokenWithLogin (_settings.AccountName, _settings.Password, token.Token); _output.WriteLine($"Server response: {validateTokenResult.HttpStatusCode}"); string validatedToken = JsonConvert.DeserializeObject <RequestToken>(validateTokenResult.Json).Token; ValidatedToken = validatedToken; }
public async Task InitializeAsync() { try { _output.WriteLine($"{nameof(InitializeAsync)}: called {nameof(_client.CreateRequestToken)}"); var createRequestTokenResult = await _client.CreateRequestToken(); _output.WriteLine($"Server responded: {createRequestTokenResult.HttpStatusCode}, message: {createRequestTokenResult?.Json ?? "null"}"); var token = JsonConvert.DeserializeObject <RequestToken>(createRequestTokenResult.Json); _output.WriteLine($"token created: {token.Token}"); RequestToken = token.Token; } catch (Exception ex) { _output.WriteLine(ex.Message); _output.WriteLine(ex.StackTrace); } }
public async Task InitializeAsync() { try { var tokenResponse = await _client.CreateRequestToken(); var token = JsonConvert.DeserializeObject <RequestToken>(tokenResponse.Json); await _client.ValidateRequestTokenWithLogin (_settings.AccountName, _settings.Password, token.Token); var createSessionIdResult = await _client.CreateSessionId(token.Token); SessionId = JsonConvert.DeserializeObject <SessionIdResponseModel>(createSessionIdResult.Json).SessionId; _output.WriteLine($"{nameof(InitializeAsync)}: Session \"{SessionId}\" created"); } catch (Exception ex) { _output.WriteLine(ex.Message); _output.WriteLine(ex.StackTrace); } }