Esempio n. 1
0
        public async Task CreateWithAllPermissionsAsync()
        {
            // Arrange
            var name           = "My API Key with all permissions";
            var userScopesJson = @"{
				'scopes': [
					'aaa',
					'bbb',
					'ccc'
				]
			}"            ;

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri("scopes")).Respond("application/json", userScopesJson);
            mockHttp.Expect(HttpMethod.Post, Utils.GetSendGridApiUri(ENDPOINT)).Respond("application/json", SINGLE_API_KEY_JSON);

            var client  = Utils.GetFluentClient(mockHttp);
            var apiKeys = new ApiKeys(client);

            // Act
            var result = await apiKeys.CreateWithAllPermissionsAsync(name, null, CancellationToken.None).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
            result.ShouldNotBeNull();
        }