public ConfigurationSetFactoryTests()
        {
            identity = new ConfigurationIdentity("fbce468f-0950-4b5f-a7e1-8e24e746bb91");
            registry = new ConfigurationSetRegistry();
            registry.AddConfigurationSet(new TestConfiguationModule().BuildConfigurationSetModel());
            defaultOptions = new List <ExternalOption>
            {
                new ExternalOption {
                    Id = 1, Description = "testOne"
                }
            };

            additionalOption = new List <OptionDependentOnAnotherOption>
            {
                new OptionDependentOnAnotherOption {
                    Id = 1, ExternalOption = defaultOptions[0], Value = 23.3
                }
            };
            mockConfigProvider = new Mock <IConfigProvider>();
            mockConfigProvider.Setup(test => test.GetCollectionAsync(typeof(ExternalOption), It.IsAny <ConfigurationIdentity>()))
            .Returns(() => Task.FromResult <IEnumerable>(defaultOptions));
            mockConfigProvider.Setup(test => test.GetCollectionAsync(typeof(OptionDependentOnAnotherOption), It.IsAny <ConfigurationIdentity>()))
            .Returns(() => Task.FromResult <IEnumerable>(additionalOption));
            defaultConfig = new SampleConfig
            {
                LlamaCapacity  = 23,
                ExternalOption = defaultOptions[0]
            };
            var instance = new ConfigInstance <SampleConfig>(defaultConfig, identity.ClientId);

            mockConfigProvider.Setup(test => test.GetAsync(typeof(SampleConfig), identity))
            .Returns(() => Task.FromResult <ConfigInstance>(instance));
            target = new ConfigurationSetFactory(mockConfigProvider.Object, new TestOptionSetFactory(), registry);
        }
Beispiel #2
0
        public ConfigRouterTests()
        {
            clients = new List <ConfigurationClient>
            {
                new ConfigurationClient {
                    ClientId = " AplicationId-1"
                }
            };
            repository = new Mock <IConfigRepository>();
            repository.Setup(s => s.GetClientsAsync())
            .ReturnsAsync(clients);

            configSetConfig = new ConfigurationSetRegistry();
            var configSetDef = new ConfigurationSetModel <SimpleConfigSet>();

            configSetDef.GetOrInitialize(c => c.Config);
            configSetConfig.AddConfigurationSet(configSetDef);

            defaultConfig = new ConfigInstance <SimpleConfig>(new SimpleConfig {
                IntProperty = 43
            }, clients[0].ClientId);
            configurationService = new Mock <IConfigurationService>();
            configurationService.Setup(r => r.GetAsync(typeof(SimpleConfig), It.Is <ConfigurationIdentity>(arg => arg.ClientId == clients[0].ClientId))).ReturnsAsync(defaultConfig);

            responseFactory = new Mock <IConfigHttpResponseFactory>();
            responseFactory.Setup(r => r.BuildResponse(It.IsAny <HttpContext>(), defaultConfig.Configuration))
            .Returns(Task.FromResult(true));

            responseFactory = new Mock <IConfigHttpResponseFactory>();

            target = new ConfigEnpoint(new ConfigInstanceRouter(repository.Object, configurationService.Object, configSetConfig), responseFactory.Object);
        }
Beispiel #3
0
        public ConfigurationServiceTests()
        {
            var registry = new ConfigurationSetRegistry();

            registry.AddConfigurationSet(new SampleConfigSet().BuildConfigurationSetModel());
            repository = new InMemoryRepository();
            target     = new ConfigurationService(repository, new TestOptionSetFactory(), registry);
        }
        public ConfigurationServiceTests()
        {
            var registry = new ConfigurationSetRegistry();

            registry.AddConfigurationSet(new SampleConfigSet().BuildConfigurationSetModel());
            configurationSetService = new Mock <IConfigurationSetService>();
            identity = new ConfigurationIdentity(clientId);
            target   = new ConfigurationService(configurationSetService.Object, registry);
        }