コード例 #1
0
        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);
            });
        }
コード例 #2
0
        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);
            });
        }
コード例 #3
0
        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);
            });
        }
コード例 #4
0
        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;
        }