public void DeletePhoto() { // Arrange string originalFilePath = Path.Combine(".", "car.jpg"); string fileName = Guid.NewGuid().ToString(); string uploadsFolderPath = Path.Combine(".", "uploads"); string outputFolderPath = Path.Combine(".", "output"); if (!Directory.Exists(uploadsFolderPath)) { Directory.CreateDirectory(uploadsFolderPath); } if (!Directory.Exists(outputFolderPath)) { Directory.CreateDirectory(outputFolderPath); } var uploadFilePath = Path.Combine(uploadsFolderPath, fileName); var outputFilePath = Path.Combine(outputFolderPath, fileName); File.Copy(originalFilePath, uploadFilePath); File.Copy(originalFilePath, outputFilePath); var filePhotoStorage = new FileSystemPhotoStorage(); // Assert #1 Assert.True(File.Exists(uploadFilePath)); Assert.True(File.Exists(outputFilePath)); // Act filePhotoStorage.DeletePhoto(fileName, uploadsFolderPath, outputFolderPath); // Assert #2 Assert.False(File.Exists(uploadFilePath)); Assert.False(File.Exists(outputFilePath)); }
public async Task StorePhoto() { // Arrange string originalFilePath = Path.Combine(".", "car.jpg"); string uploadsFolderPath = Path.Combine(".", "uploads"); if (!Directory.Exists(uploadsFolderPath)) { Directory.CreateDirectory(uploadsFolderPath); } IFormFile file = GetFormFile(originalFilePath); var filePhotoStorage = new FileSystemPhotoStorage(); // Act var result = await filePhotoStorage.StorePhoto(file, uploadsFolderPath); // Assert string expectedFilePath = Path.Combine(uploadsFolderPath, result); Assert.True(File.Exists(expectedFilePath)); File.Delete(expectedFilePath); }