public static UpdatePackageResponse Unmarshall(UnmarshallerContext context)
        {
            UpdatePackageResponse updatePackageResponse = new UpdatePackageResponse();

            updatePackageResponse.HttpResponse = context.HttpResponse;
            updatePackageResponse.RequestId    = context.StringValue("UpdatePackage.RequestId");

            return(updatePackageResponse);
        }
示例#2
0
        public async Task UpdatePackageAsync_ValidRequest_ShouldReturnUpdatePackage()
        {
            // Arrange
            var existingProject = new GetProjectPayload
            {
                Id = Guid.NewGuid().ToString(),
            };

            var existingPackage = new GetPackagePayload
            {
                Id          = Guid.NewGuid().ToString(),
                Description = "TestDescription",
            };

            var updatePackageRequest = new UpdatePackageRequest
            {
                Description = "NewDescription",
            };

            var expectedUpdatedPackage = new UpdatePackageResponse
            {
                Id          = existingPackage.Id,
                Description = updatePackageRequest.Description,
            };

            var expectedResponseContent = new StringContent(JsonConvert.SerializeObject(expectedUpdatedPackage, this.fixture.JsonSerializerSettings));

            var expectedResponse = new HttpResponseMessage
            {
                Content = expectedResponseContent,
            };

            var packageApi = this.fixture.GetPackageApi(expectedResponse);

            var updatePackageResponse = new UpdatePackageResponse();

            // Act
            Func <Task> act = async() =>
                              updatePackageResponse = await packageApi.UpdatePackageAsync(existingProject.Id, existingPackage.Id, updatePackageRequest);

            // Assert
            await act.Should().NotThrowAsync();

            using (new AssertionScope())
            {
                updatePackageResponse.Id.Should().Be(existingPackage.Id);
                updatePackageResponse.Description.Should().Be(expectedUpdatedPackage.Description);
            }
        }
示例#3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            UpdatePackageResponse response = new UpdatePackageResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("PackageDetails", targetDepth))
                {
                    var unmarshaller = PackageDetailsUnmarshaller.Instance;
                    response.PackageDetails = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }