public async Task ConnectAsync_WhenTenantIsInvalid_ShouldThrowHttpRequestException() { await Assert.ThrowsExceptionAsync <HttpRequestException>(async() => { var tenant = "00000000-0000-0000-0000-000000000000"; await XrmWebApiClient.ConnectAsync(new Uri(_serviceRoot), new ClientCredentials(_clientId, _secret), tenant); }); }
public async Task ConnectAsync_WhenClientSecretIsInvalid_ShouldThrowHttpRequestException() { await Assert.ThrowsExceptionAsync <HttpRequestException>(async() => { var secret = "INVALID_CLIENT_SECRET"; await XrmWebApiClient.ConnectAsync(new Uri(_serviceRoot), new ClientCredentials(_clientId, secret), _tenant); }); }
public async Task ConnectAsync_WhenResourceUriIsInvalid_ShouldThrowHttpRequestException() { await Assert.ThrowsExceptionAsync <HttpRequestException>(async() => { var resourceUri = "https://invalid.resource.uri"; await XrmWebApiClient.ConnectAsync(new Uri(resourceUri), new ClientCredentials(_clientId, _secret), _tenant); }); }
private void InitializeTestConnection(IConfigurationRoot configuration) { var connection = configuration.GetSection("TestConnection"); _tenant = connection["Tenant"] ?? throw new ArgumentNullException("Tenant"); _serviceRoot = connection["ServiceRoot"] ?? throw new ArgumentNullException("Resource"); var credential = connection.GetSection("Credentials"); _clientId = credential["ClientId"] ?? throw new ArgumentNullException("ClientId"); _secret = credential["Secret"] ?? throw new ArgumentNullException("Secret"); _xrmWebApiClient = XrmWebApiClient .ConnectAsync(new Uri(_serviceRoot), new ClientCredentials(_clientId, _secret), _tenant).Result; }