public void Id_Generateor_Tests() { var storagePath = StoragePaths.CreateStorageFolder(); var core = new Core(storagePath); // generating ids in root without any clusters Assert.Equal(1, core.GetNewStoreId()); Assert.Equal(2, core.GetNewStoreId()); // generating ids in `news` cluster Assert.Equal(1, core.GetNewStoreId("news")); Assert.Equal(2, core.GetNewStoreId("news")); Assert.Equal(3, core.GetNewStoreId("news")); Assert.Equal(4, core.GetNewStoreId("news")); // generating ids in `articles` cluster Assert.Equal(1, core.GetNewStoreId("articles")); Assert.Equal(2, core.GetNewStoreId("articles")); Assert.Equal(3, core.GetNewStoreId("articles")); }
/// <summary> /// add... /// </summary> /// <param name="theCandidate">the candidate (authority)</param> /// <returns>the newly added local authority</returns> public async Task <ILocalAuthority> Add(IncomingLocalAuthority theCandidate) { It.IsNull(theCandidate) .AsGuard <ArgumentNullException>(nameof(theCandidate)); var theTouchpoint = theCandidate.TouchpointID; It.IsEmpty(theTouchpoint) .AsGuard <ArgumentNullException>(nameof(theTouchpoint)); var theAdminDistrict = theCandidate.LADCode; It.IsNull(theAdminDistrict) .AsGuard <ArgumentNullException>(nameof(theAdminDistrict)); var usingAuthorityPath = StoragePaths.GetLocalAuthorityResourcePathFor(theAdminDistrict); (await DocumentStore.DocumentExists <LocalAuthority>(usingAuthorityPath, _partitionKey)) .AsGuard <ConflictingResourceException>(); return(await DocumentStore.AddDocument(theCandidate, StoragePaths.LocalAuthorityCollection)); }
private static void ConfigureWebApps(IApplicationBuilder app, GlobalVariablesService globalVariablesService, PackageManagerService packageManagerService) { var storagePaths = new StoragePaths(); var customContentRootPath = Path.Combine(storagePaths.DataPath, "CustomContent"); var packagesRootPath = Path.Combine(storagePaths.DataPath, "Packages"); var storageService = new StorageService(new JsonSerializerService(), new LoggerFactory().CreateLogger <StorageService>()); storageService.Start(); if (storageService.TryRead(out PackageManagerServiceOptions repositoryServiceOptions, PackageManagerServiceOptions.Filename)) { if (!string.IsNullOrEmpty(repositoryServiceOptions.RootPath)) { packagesRootPath = repositoryServiceOptions.RootPath; } } app.UseFileServer(new FileServerOptions { RequestPath = "/app", FileProvider = new PackageFileProvider(GlobalVariableUids.AppPackageUid, globalVariablesService, packageManagerService) }); app.UseFileServer(new FileServerOptions { RequestPath = "/configurator", FileProvider = new PackageFileProvider(GlobalVariableUids.ConfiguratorPackageUid, globalVariablesService, packageManagerService) }); // Open the configurator by default if no path is specified. var option = new RewriteOptions(); option.AddRedirect("^$", "/configurator"); app.UseRewriter(option); ExposeDirectory(app, "/customContent", customContentRootPath); ExposeDirectory(app, "/packages", packagesRootPath); }
/// <summary> /// Gets the <see cref="System.String"/> path of the given <see cref="ErrorControlSystem.CacheErrors.StoragePaths"/> path. /// </summary> /// <param name="path">The <see cref="ErrorControlSystem.CacheErrors.StoragePaths"/> path.</param> /// <returns>Converted path + app caching folders</returns> public static String GetPath(this StoragePaths path) { string dataDir; switch (path) { case StoragePaths.LocalApplicationData: // LocalApplicationData: "C:\Users\[UserName]\AppData\Local" dataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); break; case StoragePaths.InternetCache: dataDir = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache); break; case StoragePaths.CurrentDirectory: // CurrentDirectory: "App Executable File Path\" dataDir = Environment.CurrentDirectory; break; case StoragePaths.WindowsTemp: // WindowsTemp: "App Executable File Path\" dataDir = Path.GetTempPath(); break; case StoragePaths.Custom: dataDir = ErrorHandlingOption.CustomStoragePath; break; default: // default value is LocalApplicationData dataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); break; } // Application Name and Major Version var appNameVer = String.Format(Connection.GetRunningAppNameVersion()); // Storage Path LocalApplicationData\[AppName] v[AppMajorVersion]\ return(Path.Combine(dataDir, appNameVer)); }
public CoreTests() { StoragePaths.CleanRoots(); StoragePath = StoragePaths.CreateStorageFolder(); }
/// <summary> /// get... /// </summary> /// <param name="theTouchpoint">the touchpoint (id)</param> /// <returns>an area routing detail (the touchpoint)</returns> public async Task <IRoutingDetail> Get(string theTouchpoint) { var usingPath = StoragePaths.GetRoutingDetailResourcePathFor(theTouchpoint); return(await DocumentStore.GetDocument <RoutingDetail>(usingPath, _partitionKey)); }
public FileStoreTests() { StoragePaths.CleanRoots(); StoragePath1 = StoragePaths.CreateStorageFolder(); StoragePath2 = StoragePaths.CreateStorageFolder(); }
public FileCacheTests() { StoragePaths.CleanRoots(); }
/// <summary> /// delete... /// </summary> /// <param name="theAdminDistrict">the admin distict (code)</param> /// <returns>the currently running task</returns> public async Task Delete(string theAdminDistrict) { var usingPath = StoragePaths.GetLocalAuthorityResourcePathFor(theAdminDistrict); await DocumentStore.DeleteDocument(usingPath, _partitionKey); }
/// <summary> /// get (the) local authority for... /// </summary> /// <param name="theAdminDistrict">the admin distict (code)</param> /// <returns>a local authority</returns> public async Task <ILocalAuthority> Get(string theAdminDistrict) { var usingPath = StoragePaths.GetLocalAuthorityResourcePathFor(theAdminDistrict); return(await DocumentStore.GetDocument <LocalAuthority>(usingPath, _partitionKey)); }