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());
        }
Exemple #3
0
        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);
        }
Exemple #6
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"));
        }
Exemple #7
0
 public TarBalTest()
 {
     _hostStorageProvider = new StorageHostFullPathFilesystem();
 }
Exemple #8
0
 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);
        }