Beispiel #1
0
        public async Task can_get_activity_profile_with_dynamic_document()
        {
            // Arrange
            var request = new GetActivityProfileRequest()
            {
                ActivityId = new Uri(ACTIVITY_ID),
                ProfileId  = PROFILE_ID
            };

            this._mockHttp
            .When(HttpMethod.Get, this.GetApiUrl("activities/profile"))
            .WithQueryString("activityId", ACTIVITY_ID)
            .WithQueryString("profileId", PROFILE_ID)
            .Respond(this.GetActivityProfileResponseMessage());

            // Act
            ActivityProfileDocument activityProfile = await this._client.ActivityProfiles.Get(request);

            // Assert
            activityProfile.Should().NotBeNull();
            activityProfile.ETag.Should().Be(ETAG);
            activityProfile.LastModified.Should().Be(LAST_MODIFIED);
            string content = activityProfile.Content.ToObject <string>();

            content.Should().NotBeNullOrEmpty();
        }
Beispiel #2
0
        public void cannot_get_activity_profile_when_unauthorized()
        {
            // Arrange
            var request = new GetActivityProfileRequest()
            {
                ActivityId = new Uri(ACTIVITY_ID),
                ProfileId  = PROFILE_ID
            };

            this._mockHttp
            .When(HttpMethod.Get, this.GetApiUrl("activities/profile"))
            .WithQueryString("activityId", ACTIVITY_ID)
            .WithQueryString("profileId", PROFILE_ID)
            .Respond(HttpStatusCode.Forbidden);

            // Act
            Func <Task> action = async() =>
            {
                await this._client.ActivityProfiles.Get(request);
            };

            // Assert
            action.ShouldThrow <ForbiddenException>();
        }
Beispiel #3
0
        async Task <ActivityProfileDocument <T> > IActivityProfilesApi.Get <T>(GetActivityProfileRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            request.Validate();

            var options = new RequestOptions(ENDPOINT);

            this.CompleteOptions(options, request);

            HttpResponseMessage response = await this._client.GetJson(options);

            T content = await response.Content.ReadAsAsync <T>(new[] { new StrictJsonMediaTypeFormatter() });

            var document = new ActivityProfileDocument <T>();

            document.ETag         = response.Headers.ETag?.Tag;
            document.LastModified = response.Content.Headers.LastModified;
            document.Content      = content;

            return(document);
        }
Beispiel #4
0
 private void CompleteOptions(RequestOptions options, GetActivityProfileRequest request)
 {
     this.CompleteOptionsBase(options, request);
 }