Esempio n. 1
0
        private bool ReferencesHost(ModuleDefinition assembly)
        {
            var hostName = HostAssembly.GetName();

            return(assembly.AssemblyReferences
                   .Any(x => x.Name.Equals(hostName.Name, StringComparison.InvariantCultureIgnoreCase)));
        }
Esempio n. 2
0
        private bool ReferencesHost(Assembly assembly)
        {
            var hostName = HostAssembly.GetName();

            return(assembly.GetReferencedAssemblies()
                   .Any(x => x.Name.Equals(hostName.Name, StringComparison.InvariantCultureIgnoreCase)));
        }
Esempio n. 3
0
        public async Task InitializeAsync()
        {
            var hostBuilder = new HostBuilder()
                              .ConfigureWebHost(builder =>
            {
                builder.UseTestServer();

                builder.ConfigureAppConfiguration((context, b) =>
                {
                    if (HostAssembly is not null)
                    {
                        context.HostingEnvironment.ApplicationName = HostAssembly.GetName().Name;
                    }
                });

                if (IsDevelopment)
                {
                    builder.UseSetting("Environment", "Development");
                }
                else
                {
                    builder.UseSetting("Environment", "Production");
                }

                builder.ConfigureServices(ConfigureServices);
                builder.Configure(ConfigureApp);
            });

            // Build and start the IHost
            var host = await hostBuilder.StartAsync();

            Server        = host.GetTestServer();
            BrowserClient = new TestBrowserClient(Server.CreateHandler());
            HttpClient    = Server.CreateClient();
        }