public async Task CanUpdateContentFile() { var authorizedClient = SystemTestExtension.GetTokenAuthorizeHttpClient(_factory); var updateContentFileCommand = new UpdateContentFileCommand { Id = Guid.Parse("4f2b88e3-704c-41d8-a679-f608a159d055"), Name = "contentFile1", ContentType = "contentFile1", Data = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 } }; var serializedUpdateCommand = JsonConvert.SerializeObject(updateContentFileCommand); // The endpoint or route of the controller action. var httpResponse = await authorizedClient.PutAsync(requestUri : "/ContentFile", content : new StringContent(content: serializedUpdateCommand, encoding: Encoding.UTF8, mediaType: StringConstants.ApplicationJson)); //Must be successful httpResponse.EnsureSuccessStatusCode(); Assert.True(httpResponse.IsSuccessStatusCode); Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode); }
public async Task ShouldGetModelForValidInformation() { var updateContentFile = new UpdateContentFileCommand { Id = _contentFileId, TenantId = _tenantId, UpdatedBy = _adminUserId, Data = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }, Name = "contentFile1", ContentType = "image/jpeg" }; var contentFileModel = await _updateContentFileCommandHandler.Handle(updateContentFile, CancellationToken.None); Assert.Null(contentFileModel.Errors); }
public async Task <ActionResult <ResponseModel <UpdateContentFileModel> > > Put([FromBody] UpdateContentFileCommand command) { try { command.UpdatedBy = Claims[ClaimTypes.Sid].ToInt(); command.TenantId = Guid.Parse(Claims[ClaimTypes.UserData]); var updateContentFileModel = await Mediator.Send(command); return(Ok(updateContentFileModel)); } catch (NotFoundException) { return(NotFound()); } catch (ObjectAlreadyExistsException ex) { return(Conflict(new ResponseModel <UpdateContentFileModel>(new Error(HttpStatusCode.Conflict, ex)))); } catch { return(StatusCode(HttpStatusCode.InternalServerError.ToInt())); } }