private byte[] StreamToBytes(string path) { using var input = new StorageHostFullPathFilesystem(new FakeIWebLogger()).ReadStream(path); using var ms = new MemoryStream(); input.CopyTo(ms); input.Dispose(); return(ms.ToArray()); }
public void Files_GetFilesRecursiveTest() { var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar; var content = new StorageHostFullPathFilesystem().GetAllFilesInDirectoryRecursive(path); Console.WriteLine("count => " + content.Count()); // Gives a list of the content in the temp folder. Assert.AreEqual(true, content.Any()); }
public async Task ResizeThumbnailToStream__HostDependency__JPEG_Test() { var newImage = new CreateAnImage(); var iStorage = new StorageHostFullPathFilesystem(); // string subPath, int width, string outputHash = null,bool removeExif = false,ExtensionRolesHelper.ImageFormat // imageFormat = ExtensionRolesHelper.ImageFormat.jpg var thumb = await new Thumbnail(iStorage, iStorage, new FakeIWebLogger()).ResizeThumbnailFromSourceImage( newImage.FullFilePath, 1, null, true); Assert.AreEqual(true, thumb.Item1.CanRead); }
public void FolderDelete_ChildFoldersAreDeleted() { var rootDir = Path.Combine(new CreateAnImage().BasePath, "test01010"); var childDir = Path.Combine(new CreateAnImage().BasePath, "test01010", "included-folder"); var realStorage = new StorageHostFullPathFilesystem(); realStorage.CreateDirectory(rootDir); realStorage.CreateDirectory(childDir); realStorage.FolderDelete(rootDir); Assert.AreEqual(false, realStorage.ExistFolder(rootDir)); Assert.AreEqual(false, realStorage.ExistFolder(childDir)); }
public void GetAllFilesInDirectoryRecursive_NotFound() { var logger = new FakeIWebLogger(); var realStorage = new StorageHostFullPathFilesystem(logger); var directories = realStorage.GetAllFilesInDirectoryRecursive("NOT:\\t"); if (new AppSettings().IsWindows) { Assert.IsTrue(logger.TrackedInformation.LastOrDefault().Item2.Contains("The filename, directory name, or volume label syntax is incorrect")); } else { Assert.IsTrue(logger.TrackedInformation.LastOrDefault().Item2.Contains("Could not find a part of the path")); } Assert.AreEqual(directories.Count(), 0); }
/// <summary> /// Check if the .zip file exist and if its larger then MinimumSizeInBytes /// </summary> private void RemoveFailedDownload() { if (!new StorageHostFullPathFilesystem().ExistFile(Path.Combine(_appSettings.TempFolder, CountryName + ".zip"))) { return; } // When trying to download a file var zipLength = new StorageHostFullPathFilesystem() .ReadStream(Path.Combine(_appSettings.TempFolder, CountryName + ".zip")) .Length; if (zipLength > MinimumSizeInBytes) { return; } new StorageHostFullPathFilesystem().FileDelete(Path.Combine(_appSettings.TempFolder, CountryName + ".zip")); }
public TarBalTest() { _hostStorageProvider = new StorageHostFullPathFilesystem(); }
public SetupAppSettingsTest() { _hostStorage = new StorageHostFullPathFilesystem(); }
public void InfoNotFound() { var info = new StorageHostFullPathFilesystem().Info("C://folder-not-found-992544124712741"); Assert.AreEqual(FolderOrFileModel.FolderOrFileTypeList.Deleted, info.IsFolderOrFile); }