public Task <IActionResult> UpdateTemplateVersion( [FromRoute] Guid templateId, [FromRoute] Guid templateVersionId, [FromBody] UpdateTemplateVersion updateTemplateVersionBody, CancellationToken cancellationToken) { return(SafeInvoke(async() => { await _templateManager.UpdateTemplateVersion(templateId, templateVersionId, updateTemplateVersionBody.Content, cancellationToken); return AcceptedAtRoute("TemplateVersionDetails", new { templateId, templateVersionId }, null); })); }
public async Task Produces_404NotFound_On_TemplateVersionNotFoundException() { var templateId = Guid.NewGuid(); var templateVersionId = Guid.NewGuid(); var content = "lorem ipsum"; var ct = CancellationToken.None; _templateManager.Setup(x => x.UpdateTemplateVersion(templateId, templateVersionId, content, ct)) .ThrowsAsync(new TemplateVersionNotFoundException(templateId, templateVersionId)); var request = new UpdateTemplateVersion { Content = content }; var result = await _controller.UpdateTemplateVersion(templateId, templateVersionId, request, ct); result.Should().BeOfType(typeof(NotFoundResult)); }
public async Task Produces_202Accepted() { var templateId = Guid.NewGuid(); var templateVersionId = Guid.NewGuid(); var content = "lorem ipsum"; var ct = CancellationToken.None; _templateManager.Setup(x => x.UpdateTemplateVersion(templateId, templateVersionId, content, ct)) .Verifiable(); var request = new UpdateTemplateVersion() { Content = content }; var result = await _controller.UpdateTemplateVersion(templateId, templateVersionId, request, ct) as AcceptedAtRouteResult; result.Should().NotBeNull(); result.RouteName.Should().Be("TemplateVersionDetails"); result.RouteValues["templateId"].Should().Be(templateId); result.RouteValues["templateVersionId"].Should().Be(templateVersionId); _templateManager.Verify(); }