Exemplo n.º 1
0
        public void CanAddConfigRegistry()
        {
            var config = new SimpleConfig {
                IntProperty = 23
            };
            var applicationId = "3E37AC18-A00F-47A5-B84E-C79E0823F6D4";
            var builder       = serviceCollection.AddConfigServer()
                                .UseInMemoryProvider()
                                .UseLocalConfigServerClient(applicationId)
                                .WithConfig <SimpleConfig>();
            var regs = builder.ConfigurationRegistry.ToList();

            Assert.Equal(1, regs.Count);
            Assert.Equal(typeof(SimpleConfig).Name, regs[0].ConfigurationName);
        }
Exemplo n.º 2
0
        public void ConfigRegistry_IsAdded()
        {
            var config = new SimpleConfig {
                IntProperty = 23
            };
            var applicationId = "3E37AC18-A00F-47A5-B84E-C79E0823F6D4";
            var builder       = serviceCollection.AddConfigServer()
                                .UseInMemoryProvider()
                                .UseLocalConfigServerClient(testUri)
                                .WithClientId(applicationId)
                                .WithConfig <SimpleConfig>();
            var serviceProvider = serviceCollection.BuildServiceProvider();
            var configRepo      = serviceProvider.GetRequiredService <IConfigurationRegistry>();
            var regs            = configRepo.ToList();

            Assert.Single(regs);
            Assert.Equal(typeof(SimpleConfig).Name, regs[0].ConfigurationName);
        }
        public async Task CanSetUpSimpleInMemoryConfig()
        {
            var config = new SimpleConfig {
                IntProperty = 23
            };
            var applicationId = "3E37AC18-A00F-47A5-B84E-C79E0823F6D4";

            serviceCollection.AddConfigServer()
            .UseInMemoryProvider()
            .UseLocalConfigServerClient(applicationId)
            .WithConfig <SimpleConfig>();
            var serviceProvider = serviceCollection.BuildServiceProvider();
            var configRepo      = serviceProvider.GetService <IConfigRepository>();
            await configRepo.UpdateConfigAsync(new ConfigInstance <SimpleConfig>(config, applicationId));

            var configFromServer = serviceProvider.GetService <SimpleConfig>();

            Assert.Equal(config.IntProperty, configFromServer.IntProperty);
        }