Ejemplo n.º 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));
 }
Ejemplo n.º 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>();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }