public void EnsureExceptionGivenForBadApiCredentials() { var cmd = new GetAuthTokenCommand() { RequestHandler = new MockApiRequestHandler(FakeResponse.Unauthorized()), OAuth2 = new OAuth2(null), AuthorizationCode = "code", ClientId = "test", ClientSecret = "test", ClientSettings = new MockMusicClientSettings(null, "test", null) }; var task = cmd.InvokeAsync(); task.Wait(); Response <TokenResponse> t = task.Result; Assert.IsNull(t.Result, "Expected no result"); Assert.IsNotNull(t.Error, "Expected an error"); Assert.AreNotEqual(typeof(InvalidApiCredentialsException), t.Error.GetType()); }
public void EnsureResponseParsedForValidRefreshTokenRequest() { var cmd = new GetAuthTokenCommand() { RequestHandler = new MockApiRequestHandler(FakeResponse.Success(Resources.token_response, MusicClientCommand.ContentTypeJson)), OAuth2 = new OAuth2(null), RefreshToken = "token", ClientId = "test", ClientSecret = "test", ClientSettings = new MockMusicClientSettings("test", "gb", null) }; var task = cmd.InvokeAsync(); task.Wait(); Response <TokenResponse> t = task.Result; Assert.IsNotNull(t.Result, "Expected a result"); Assert.IsNotNullOrEmpty(t.Result.AccessToken, "Expected an access token"); Assert.IsTrue(t.Result.ExpiresIn > 0, "Expected expires > 0"); Assert.IsNotNullOrEmpty(t.Result.AccessToken, "Expected a refresh token"); Assert.IsNotNull(t.Result.UserId, "Expected a user id"); Assert.IsNotNullOrEmpty(t.Result.Territory, "Expected territory"); }
public void EnsureExceptionGivenForBadApiCredentials() { var cmd = new GetAuthTokenCommand() { RequestHandler = new MockApiRequestHandler(FakeResponse.Unauthorized()), OAuth2 = new OAuth2(null), AuthorizationCode = "code", ClientId = "test", ClientSecret = "test", ClientSettings = new MockMusicClientSettings(null, "test", null) }; var task = cmd.InvokeAsync(); task.Wait(); Response<TokenResponse> t = task.Result; Assert.IsNull(t.Result, "Expected no result"); Assert.IsNotNull(t.Error, "Expected an error"); Assert.AreNotEqual(typeof(InvalidApiCredentialsException), t.Error.GetType()); }
public void EnsureResponseParsedForValidRefreshTokenRequest() { var cmd = new GetAuthTokenCommand() { RequestHandler = new MockApiRequestHandler(FakeResponse.Success(Resources.token_response, MusicClientCommand.ContentTypeJson)), OAuth2 = new OAuth2(null), RefreshToken = "token", ClientId = "test", ClientSecret = "test", ClientSettings = new MockMusicClientSettings("test", "gb", null) }; var task = cmd.InvokeAsync(); task.Wait(); Response<TokenResponse> t = task.Result; Assert.IsNotNull(t.Result, "Expected a result"); Assert.IsNotNullOrEmpty(t.Result.AccessToken, "Expected an access token"); Assert.IsTrue(t.Result.ExpiresIn > 0, "Expected expires > 0"); Assert.IsNotNullOrEmpty(t.Result.AccessToken, "Expected a refresh token"); Assert.IsNotNull(t.Result.UserId, "Expected a user id"); Assert.IsNotNullOrEmpty(t.Result.Territory, "Expected territory"); }