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)); }
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>(); }
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(); }
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); }
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); }
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); }
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); }
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); }