예제 #1
0
 public UpdateRequest(UpdateFromRoute route, UpdateFromQuery query, UpdateFromHeader header, UpdateFromBody body)
 {
     _route  = route ?? throw new ArgumentNullException(nameof(route));
     _query  = query ?? throw new ArgumentNullException(nameof(query));
     _header = header ?? throw new ArgumentNullException(nameof(header));
     _body   = body ?? throw new ArgumentNullException(nameof(body));
 }
예제 #2
0
        public void ConstructorShouldFailWhenBodyIsNull()
        {
            // Arrange
            var            route  = new UpdateFromRoute();
            var            query  = new UpdateFromQuery();
            var            header = new UpdateFromHeader();
            UpdateFromBody body   = null;

            // Act
            Action ctor = () => { new UpdateRequest(route, query, header, body); };

            // Assert
            ctor.Should().Throw <ArgumentNullException>();
        }
예제 #3
0
        public void ConstructorShouldSucceed()
        {
            // Arrange
            var route  = new UpdateFromRoute();
            var query  = new UpdateFromQuery();
            var header = new UpdateFromHeader();
            var body   = new UpdateFromBody();

            // Act
            var obj = new UpdateRequest(route, query, header, body);

            // Assert
            obj.Should().NotBeNull();
        }
예제 #4
0
        public async Task <IActionResult> Update([FromRoute] UpdateFromRoute route,
                                                 [FromQuery] UpdateFromQuery query,
                                                 [FromHeader] UpdateFromHeader header)
        {
            string bodyAsString = await Request.GetRawBodyStringAsync();

            var body = new UpdateFromBody {
                Patch = bodyAsString
            };

            var request = new UpdateRequest(route, query, header, body);

            var result = await _apiResult.Produce(request);

            return(result);
        }
예제 #5
0
        public void MemberRouteIdShouldHaveCorrectValue()
        {
            // Arrange
            var routeId = Guid.NewGuid().ToString();
            var route   = new UpdateFromRoute()
            {
                Id = routeId
            };
            var query  = new UpdateFromQuery();
            var header = new UpdateFromHeader();
            var body   = new UpdateFromBody();

            // Act
            var obj = new UpdateRequest(route, query, header, body);

            // Assert
            obj.RouteId.Should().Be(routeId);
        }
예제 #6
0
        public void MemberBodyPatchShouldHaveCorrectValue()
        {
            // Arrange
            var patch  = "json";
            var route  = new UpdateFromRoute();
            var query  = new UpdateFromQuery();
            var header = new UpdateFromHeader();
            var body   = new UpdateFromBody()
            {
                Patch = patch
            };

            // Act
            var obj = new UpdateRequest(route, query, header, body);

            // Assert
            obj.BodyPatch.Should().Be(patch);
        }
예제 #7
0
        public void MemberQueryApiVersionShouldHaveCorrectValue()
        {
            // Arrange
            var apiVersion = "1.0";
            var route      = new UpdateFromRoute();
            var query      = new UpdateFromQuery()
            {
                ApiVersion = apiVersion
            };
            var header = new UpdateFromHeader();
            var body   = new UpdateFromBody();

            // Act
            var obj = new UpdateRequest(route, query, header, body);

            // Assert
            obj.QueryApiVersion.Should().Be(apiVersion);
        }
예제 #8
0
        public void MembersHeaderShouldHaveCorrectValue()
        {
            // Arrange
            var contentType = "application/json";
            var ifMatch     = "3452353445435";

            var route  = new UpdateFromRoute();
            var query  = new UpdateFromQuery();
            var header = new UpdateFromHeader()
            {
                IfMatch = ifMatch, ContentType = contentType
            };
            var body = new UpdateFromBody();


            // Act
            var obj = new UpdateRequest(route, query, header, body);

            // Assert
            obj.HeaderContentType.Should().Be(contentType);
            obj.HeaderIfMatch.Should().Be(ifMatch);
        }