Example #1
0
        public async Task SetLocalAppData_ShouldRead()
        {
            var appDataFolderFullPath =
                Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "setup_app_settings_test");

            _hostStorage.CreateDirectory(appDataFolderFullPath);
            var path = Path.Combine(appDataFolderFullPath, "appsettings.json");

            var example =
                new PlainTextFileHelper().StringToStream(
                    "{\n \"app\" :{\n   \"isAccountRegisterOpen\": \"true\"\n }\n}\n");

            await _hostStorage.WriteStreamAsync(example, path);

            Environment.SetEnvironmentVariable("app__appsettingspath", path);
            var builder = await SetupAppSettings.AppSettingsToBuilder();

            var services    = new ServiceCollection();
            var appSettings = SetupAppSettings.ConfigurePoCoAppSettings(services, builder);

            Assert.IsFalse(string.IsNullOrEmpty(appSettings.AppSettingsPath));
            Assert.IsTrue(appSettings.IsAccountRegisterOpen);
            Assert.AreEqual(path, appSettings.AppSettingsPath);

            _hostStorage.FolderDelete(appDataFolderFullPath);
            Environment.SetEnvironmentVariable("app__appsettingspath", null);
        }
        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));
        }