public async Task <IHttpActionResult> PutRightFileAsync(int diffId, [FromBody] FileContentDTO fileContent) { if (string.IsNullOrEmpty(fileContent.Data)) { return(BadRequest()); } await _uploadService.UploadRightAsync(diffId, Convert.FromBase64String(fileContent.Data)); return(new CreatedFileActionResult(Request)); }
public async Task EmptyDb_PutLeftFile_Created() { // Arrange var controller = await Task.Run(() => GetController()); var leftFile = new FileContentDTO() { Data = TestConstants.File1Base64Content }; // Act var result = await controller.PutLeftFileAsync(1, leftFile); //Assert Assert.IsInstanceOfType(result, typeof(CreatedFileActionResult), "The action result should be 201-Created!"); }
public async Task ExistingDbWithSameFile_PutRightFile_Created() { // Arrange var controller = await Task.Run(() => GetController()); var rightFile = new FileContentDTO() { Data = TestConstants.FileIdenticalSizeNonIdenticalContentBase64Content }; // Act var result = await controller.PutRightFileAsync(1, rightFile); //Assert Assert.IsInstanceOfType(result, typeof(CreatedFileActionResult), "The action result should be 201-Created!"); }
public async Task ExistingDbWithDifferentSizeFile_PutLeftFileEmpty_BadRequest() { // Arrange var controller = await Task.Run(() => GetController()); var leftFile = new FileContentDTO() { Data = string.Empty }; // Act var result = await controller.PutLeftFileAsync(1, leftFile); //Assert Assert.IsNotNull(result, "The action result should not be null!"); Assert.IsInstanceOfType(result, typeof(BadRequestResult), "The action result should be 400-BadRequest!"); }
public async Task EmptyFile_PutRightFile_BadRequest() { // Arrange const int id = 1; var mockDiffService = new Mock <IDiffService>(); var mockRetrieveService = new Mock <IRetrieveService>(); var mockUploadService = new Mock <IUploadService>(); var rightFile = new FileContentDTO() { Data = string.Empty }; var controller = new FileDiffController(mockDiffService.Object, mockRetrieveService.Object, mockUploadService.Object); // Act var result = await controller.PutRightFileAsync(id, rightFile); // Assert Assert.IsNotNull(result, "The action result should not be null!"); Assert.IsInstanceOfType(result, typeof(BadRequestResult), "The action result should be 400-BadRequest!"); }