public async Task WhenExceptionThenUploadFileReturnsInternalServerError() { // Arrange var fileInfoViewModel = new FileInfoViewModel { }; var fileInfoServiceMock = new Mock <IFileInfoService>(); var fileInfoController = new FileInfoController(fileInfoServiceMock.Object); // Act var contentResult = (ContentResult)await fileInfoController.UploadFile(fileInfoViewModel); // Assert contentResult.ShouldNotBeNull(); contentResult.StatusCode.ShouldBe((int)HttpStatusCode.InternalServerError); }
public async Task WhenNoExceptionThenUploadFileReturnsCreated() { // Arrange var fileInfoViewModel = new FileInfoViewModel { }; var fileInfoViewModelFromSave = new FileInfoViewModel { }; var fileInfoServiceMock = new Mock <IFileInfoService>(); var fixture = new Fixture(); fileInfoServiceMock.Setup(fileInfoService => fileInfoService.SaveFile(fileInfoViewModel)) .ReturnsAsync(new FileInfoViewModel { Id = fixture.Create <int>() }); var fileInfoController = new FileInfoController(fileInfoServiceMock.Object); // Act var createdAtActionResult = (CreatedAtActionResult)await fileInfoController.UploadFile(fileInfoViewModel); // Assert createdAtActionResult.ShouldNotBeNull(); createdAtActionResult.StatusCode.ShouldBe((int)HttpStatusCode.Created); }