public ConfigEndpointTests()
        {
            clients = new List <ConfigurationClient>
            {
                new ConfigurationClient {
                    ClientId = " AplicationId-1"
                }
            };
            repository = new Mock <IConfigurationClientService>();
            repository.Setup(s => s.GetClientOrDefault(It.IsAny <string>()))
            .Returns((string value) => Task.FromResult(clients.SingleOrDefault(s => string.Equals(value, s.ClientId, StringComparison.OrdinalIgnoreCase))));

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

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

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

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

            responseFactory = new Mock <IHttpResponseFactory>();
            options         = new ConfigServerOptions();
            target          = new ConfigEndpoint(new ConfigInstanceRouter(repository.Object, configurationService.Object, configSetConfig), repository.Object, responseFactory.Object);
        }
        public ConfigurationSetFactoryTests()
        {
            identity = new ConfigurationIdentity(new ConfigurationClient("fbce468f-0950-4b5f-a7e1-8e24e746bb91"), new Version(1, 0));
            registry = new ConfigurationModelRegistry();
            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 TestConfig
            {
                LlamaCapacity  = 23,
                ExternalOption = defaultOptions[0]
            };
            var instance = new ConfigInstance <TestConfig>(defaultConfig, identity);

            mockConfigProvider.Setup(test => test.GetAsync(typeof(TestConfig), identity))
            .Returns(() => Task.FromResult <ConfigInstance>(instance));
            target = new ConfigurationSetFactory(mockConfigProvider.Object, new TestOptionSetFactory(), registry);
        }
        public ConfigurationServiceTests()
        {
            var registry = new ConfigurationModelRegistry();

            registry.AddConfigurationSet(new SampleConfigSet().BuildConfigurationSetModel());
            configurationSetService = new Mock <IConfigurationSetService>();
            identity = new ConfigurationIdentity(new ConfigurationClient(clientId), new Version(1, 0));
            target   = new ConfigurationService(configurationSetService.Object, registry);
        }
示例#4
0
        // GET: Gets all configuration set summaries
        public ConfigurationSetEnpointTests()
        {
            responseFactory  = new Mock <IHttpResponseFactory>();
            configCollection = new ConfigurationModelRegistry();
            var configSetModel = new ConfigurationSetModel <SampleConfigSet>("Sample", "Sample description");

            configSetModel.GetOrInitialize(set => set.SampleConfig);
            configCollection.AddConfigurationSet(configSetModel);

            target  = new ConfigurationSetEndpoint(responseFactory.Object, configCollection);
            options = new ConfigServerOptions();
        }
示例#5
0
        public TagEndpointTests()
        {
            tagOne = new Tag {
                Value = "Tag One"
            };
            tagTwo = new Tag {
                Value = "Tag Two"
            };

            registry = new ConfigurationModelRegistry();
            registry.AddConfigurationSet(Create <ConfigSetWithTagOne>(tagOne));
            registry.AddConfigurationSet(Create <ConfigSetWithTagTwo>(tagTwo));
            registry.AddConfigurationSet(Create <ConfigSetWithTagOneAgain>(tagOne));
            registry.AddConfigurationSet(Create <ConfigSetWithNoTag>(null));
            options         = new ConfigServerOptions();
            responseFactory = new Mock <IHttpResponseFactory>();
            responseFactory.Setup(r => r.BuildJsonResponse(It.IsAny <HttpContext>(), It.IsAny <IEnumerable <Tag> >()))
            .Returns(Task.FromResult(true));

            target = new TagEndpoint(responseFactory.Object, registry);
        }
示例#6
0
        public UpdateConfigurationFromJsonUploadCommandHandlerTests()
        {
            expectedIdentity = new ConfigurationIdentity(new ConfigurationClient(clientId), new Version(1, 0));
            var configSet = new SampleConfigSet();

            registry = new ConfigurationModelRegistry();
            registry.AddConfigurationSet(configSet.BuildConfigurationSetModel());
            configurationService   = new Mock <IConfigurationService>();
            configRepository       = new Mock <IConfigRepository>();
            configurationValidator = new Mock <IConfigurationValidator>();
            configurationValidator.Setup(v => v.Validate(It.IsAny <object>(), It.IsAny <ConfigurationModel>(), expectedIdentity))
            .ReturnsAsync(() => ValidationResult.CreateValid());
            eventService = new Mock <IEventService>();
            target       = new UpdateConfigurationFromJsonUploadCommandHandler(registry, configurationService.Object, configRepository.Object, configurationValidator.Object, eventService.Object, new ConfigurationUploadMapper());
        }
        // Model/{ Client Id}/{ Configuration Set}
        // GET: Model for configuration set
        public ConfigurationSetModelEnpointTests()
        {
            expectedClient     = new ConfigurationClient(clientId);
            responseFactory    = new Mock <IHttpResponseFactory>();
            modelPayloadMapper = new Mock <IConfigurationSetModelPayloadMapper>();
            configCollection   = new ConfigurationModelRegistry();
            var configSetModel = new ConfigurationSetModel <SampleConfigSet>("Sample", "Sample description");

            configSetModel.GetOrInitialize(set => set.SampleConfig);
            configCollection.AddConfigurationSet(configSetModel);
            configClientService = new Mock <IConfigurationClientService>();
            configClientService.Setup(s => s.GetClientOrDefault(clientId))
            .ReturnsAsync(expectedClient);
            target  = new ConfigurationSetModelEndpoint(responseFactory.Object, modelPayloadMapper.Object, configCollection, configClientService.Object);
            options = new ConfigServerOptions();
        }
        public DownloadEndpointTests()
        {
            var testconfigSet = new SampleConfigSet();
            var definition    = testconfigSet.BuildConfigurationSetModel();

            configCollection = new ConfigurationModelRegistry();
            configCollection.AddConfigurationSet(definition);
            responseFactory         = new Mock <IHttpResponseFactory>();
            configurationSetService = new Mock <IConfigurationSetService>();

            expectedClient      = new ConfigurationClient(clientId);
            configClientService = new Mock <IConfigurationClientService>();
            configClientService.Setup(s => s.GetClientOrDefault(clientId))
            .ReturnsAsync(() => expectedClient);
            option = new ConfigServerOptions();
            target = new DownloadEndpoint(responseFactory.Object, configCollection, configurationSetService.Object, configClientService.Object);
        }
示例#9
0
        // /ConfigurationSet/{clientId}/{Configuration Set}
        // POST: Uploads configuration set file
        // /Configuration/{clientId}/{Config name}
        // POST: Uploads configuration file
        public UploadEnpointTests()
        {
            responseFactory = new Mock <IHttpResponseFactory>();
            var testConfigSet = new SampleConfigSet();

            configCollection = new ConfigurationModelRegistry();
            configCollection.AddConfigurationSet(testConfigSet.BuildConfigurationSetModel());
            commandBus     = new Mock <ICommandBus>();
            expectedClient = new ConfigurationClient(clientId)
            {
                ConfiguratorClaim = clientConfiguratorClaim.Value
            };
            configClientService = new Mock <IConfigurationClientService>();
            configClientService.Setup(s => s.GetClientOrDefault(clientId))
            .ReturnsAsync(() => expectedClient);
            option = new ConfigServerOptions();
            uploadToEditorMapper = new Mock <IUploadToEditorModelMapper>();
            target = new UploadEnpoint(responseFactory.Object, configCollection, commandBus.Object, configClientService.Object, uploadToEditorMapper.Object);
        }