public async Task MiddlewareTestAsync( Action <IServiceCollection> configureServices, Action <IApplicationBuilder> configure, Func <HttpClient, Task> testMethod) { using (var host = new HostBuilder() .ConfigureWebHost(webBuilder => { webBuilder.UseTestServer().ConfigureServices(configureServices).Configure(configure); }).Build()) { Providers.Instance = new Providers(host.Services); using (InMemoryExtensions.StartInMemoryRepository(host.Services, repositoryBuilder => { repositoryBuilder.UseAccessProvider(new UserAccessProvider()); })) { #pragma warning disable 4014 host.RunAsync(); #pragma warning restore 4014 var client = host.GetTestServer().CreateClient(); await testMethod(client); } } }
public static void Main(string[] args) { var builder = CreateWebHostBuilder(args); var host = builder.Build(); SnTrace.EnableAll(); using (InMemoryExtensions.StartInMemoryRepository(repositoryBuilder => { repositoryBuilder .UseAccessProvider(new UserAccessProvider()) .UseLogger(new SnFileSystemEventLogger()) .UseTracer(new SnFileSystemTracer()); })) { using (new SystemAccount()) { // FOR TESTING PURPOSES: create a default user with a well-known password // login: [email protected] // password: Edvin123% var parentPath = "/Root/IMS/BuiltIn/Temp"; var parent = RepositoryTools.CreateStructure(parentPath, "OrganizationalUnit"); var user = new User(parent.ContentHandler) { Name = "edvin-example.com", LoginName = "*****@*****.**", PasswordHash = "AQAAAAEAACcQAAAAEKEsynr6baKE5rYqS4Rn6pjqckl+NG4W9UQqqGh4g23zlJQpQvnaZnzx44+z78FVsg==", Email = "*****@*****.**" }; user.Save(); // set the new user as administrator Group.Administrators.AddMember(user); // create a container for test content parent = RepositoryTools.CreateStructure("/Root/MyContent", "SystemFolder"); // create a doclib that contains a file var docLib = RepositoryTools.CreateStructure("/Root/MyContent/MyFiles", "DocumentLibrary"); ((GenericContent)docLib.ContentHandler).AllowChildType("Image", save: true); var file = new File(docLib.ContentHandler) { Name = "testfile.txt" }; file.Binary.SetStream(RepositoryTools.GetStreamFromString($"temp text data {DateTime.UtcNow}")); file.Save(); //var installer = new Installer(); //installer.Import("C:\\temp\\import\\Root"); } SnTrace.EnableAll(); host.Run(); } }
public static void Main(string[] args) { var builder = CreateHostBuilder(args); var host = builder.Build(); using (InMemoryExtensions.StartInMemoryRepository(repositoryBuilder => { repositoryBuilder.UseAccessProvider(new UserAccessProvider()); })) { // put repository initialization here (e.g. import) host.Run(); } }
public static void Main(string[] args) { var builder = CreateWebHostBuilder(args); var host = builder.Build(); SnTrace.EnableAll(); using (InMemoryExtensions.StartInMemoryRepository(repositoryBuilder => { repositoryBuilder .UseAccessProvider(new DesktopAccessProvider()) .UseLogger(new SnFileSystemEventLogger()) .UseTracer(new SnFileSystemTracer()); })) { SnTrace.EnableAll(); host.Run(); } }