Exemple #1
0
 public UpdateTeamRequest(UpdateTeamFromHeader header,
                          UpdateTeamFromQuery query,
                          UpdateTeamFromRoute route,
                          UpdateTeamFromBody body)
 {
     _header = header ?? throw new ArgumentNullException(nameof(header));
     _query  = query ?? throw new ArgumentNullException(nameof(query));
     _route  = route ?? throw new ArgumentNullException(nameof(route));
     _body   = body ?? throw new ArgumentNullException(nameof(body));
 }
        public async Task <IActionResult> Update([FromRoute] UpdateTeamFromRoute route,
                                                 [FromQuery] UpdateTeamFromQuery query,
                                                 [FromHeader] UpdateTeamFromHeader header)
        {
            var bodyString = await Request.GetRawBodyStringAsync();

            var body = JsonConvert.DeserializeObject <UpdateTeamFromBody>(bodyString);

            body.Put = bodyString;
            var request = new UpdateTeamRequest(header, query, route, body);
            var result  = await _apiResult.Produce(request);

            return(result);
        }
        public void ConstructorShouldFailWhenBodyIsNull()
        {
            // Arrange
            var header = new UpdateTeamFromHeader();
            var query  = new UpdateTeamFromQuery();
            var route  = new UpdateTeamFromRoute();
            UpdateTeamFromBody body = null;

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

            // Assert
            request.Should().Throw <ArgumentNullException>();
        }
        public void ConstructorShouldSucceed()
        {
            // Arrange
            var header = new UpdateTeamFromHeader();
            var query  = new UpdateTeamFromQuery();
            var route  = new UpdateTeamFromRoute();
            var body   = new UpdateTeamFromBody();

            // Act
            var request = new UpdateTeamRequest(header, query, route, body);

            // Assert
            request.Should().NotBeNull();
        }