public void DoIt() { IFeatureConfiguration features = new FeatureConfiguration { new BooleanToggle("Feature1", true), new DateRangeToggle( "Feature2", true, DateTime.Now.AddDays(-2), DateTime.Now.AddDays(3)), new EstablishedFeatureToggle("establishedFeature") }; var mainFeature = new BooleanToggle("mainFeature", true); var subFeature1 = new BooleanToggle("subFeature1", true); var subFeature2 = new BooleanToggle("subFeature2", true); var dependency1 = new DependencyToggle(subFeature1, mainFeature); var dependency2 = new DependencyToggle(subFeature2, mainFeature); features.Add(dependency1); features.Add(dependency2); features.Add(new EstablishedFeatureToggle("establishedFeature")); Console.WriteLine(features.WhatDoIHave()); }
public void Locate_Returns_Null_For_Toggles_Not_Found() { var featureConfiguration = new FeatureConfiguration(); var locator = new LocateByNameStrategy(featureConfiguration, "idontexist"); Assert.IsNull(locator.Locate()); }
public async Task Retrieve() { var cancellationToken = CancellationToken.None; var referenceDataContextMock = new Mock <IReferenceDataContext>(); var messageProviderMock = new Mock <IMessageProvider>(); var referenceDataPopulationServiceMock = new Mock <IReferenceDataPopulationService>(); var filePersisterMock = new Mock <IFilePersister>(); var loggerMock = new Mock <ILogger>(); var edrsApiServiceMock = new Mock <IEdrsApiService>(); IMessage message = new TestMessage(); var referenceDataRoot = new ReferenceDataRoot(); var featureConfiguration = new FeatureConfiguration { EDRSAPIEnabled = "false" }; messageProviderMock.Setup(p => p.ProvideAsync(referenceDataContextMock.Object, cancellationToken)).Returns(Task.FromResult(message)).Verifiable(); referenceDataPopulationServiceMock.Setup(s => s.PopulateAsync(referenceDataContextMock.Object, message, cancellationToken)).Returns(Task.FromResult(referenceDataRoot)).Verifiable(); filePersisterMock.Setup(s => s.StoreAsync(referenceDataContextMock.Object.OutputIlrReferenceDataFileKey, referenceDataContextMock.Object.Container, referenceDataRoot, false, cancellationToken)).Returns(Task.CompletedTask).Verifiable(); var service = NewService(messageProviderMock.Object, referenceDataPopulationServiceMock.Object, edrsApiServiceMock.Object, filePersisterMock.Object, loggerMock.Object, featureConfiguration); await service.ExecuteAsync(referenceDataContextMock.Object, cancellationToken); messageProviderMock.VerifyAll(); referenceDataPopulationServiceMock.VerifyAll(); filePersisterMock.VerifyAll(); }
private static Feature.Switch.IKnowStateOf <TFeature> InContextOf <TFeature, TContext>(this Feature.Switch.IKnowStateOf <TFeature> This, TContext instance) where TFeature : IFeature where TContext : IContext { var type = This.GetType().GetGenericArguments().First(); return(Feature.Switch.For <TFeature>(type).With(FeatureConfiguration.For(instance))); }
public TheGetMethod() { _curatedFeed = new CuratedFeed { Name = _curatedFeedName }; _curatedFeedPackage = new Package { PackageRegistration = new PackageRegistration { Id = "NuGet.Core", }, }; _mainFeedPackage = new Package { PackageRegistration = new PackageRegistration { Id = "NuGet.Versioning", }, }; _featureConfiguration = new FeatureConfiguration(); _appConfig = new Mock <IAppConfiguration>(); _config = new Mock <IGalleryConfigurationService>(); _searchService = new Mock <ISearchService>(); _curatedFeedService = new Mock <ICuratedFeedService>(); _packages = new Mock <IEntityRepository <Package> >(); _telemetryService = new Mock <ITelemetryService>(); _config .Setup(x => x.Current) .Returns(() => _appConfig.Object); _config .Setup(x => x.Features) .Returns(() => _featureConfiguration); _config .Setup(x => x.GetSiteRoot(It.IsAny <bool>())) .Returns(() => _siteRoot); _curatedFeedService .Setup(x => x.GetFeedByName(_curatedFeedName)) .Returns(() => _curatedFeed); _curatedFeedService .Setup(x => x.GetPackages(_curatedFeedName)) .Returns(() => new[] { _curatedFeedPackage }.AsQueryable()); _packages .Setup(x => x.GetAll()) .Returns(() => new[] { _mainFeedPackage }.AsQueryable()); _target = new ODataV2CuratedFeedController( _config.Object, _searchService.Object, _curatedFeedService.Object, _packages.Object, _telemetryService.Object); _request = new HttpRequestMessage(HttpMethod.Get, $"{_siteRoot}/api/v2/curated-feed/{_curatedFeedName}/Packages"); _options = new ODataQueryOptions <V2FeedPackage>(CreateODataQueryContext <V2FeedPackage>(), _request); AddRequestToController(_request, _target); }
public QueryTagServiceTests() { _extendedQueryTagStore = Substitute.For <IExtendedQueryTagStore>(); _featureConfiguration = new FeatureConfiguration() { EnableExtendedQueryTags = true }; _queryTagService = new QueryTagService(_extendedQueryTagStore, Options.Create(_featureConfiguration)); }
public ValidateController(IMediator mediator, IOptions <FeatureConfiguration> features) { EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(features, nameof(features)); EnsureArg.IsNotNull(features.Value, nameof(features)); _mediator = mediator; _features = features.Value; }
public FeatureConfigViewModel(PropertyInfo property, FeatureConfiguration config) { Property = property; var desca = property.GetCustomAttribute <DescriptionAttribute>(); Description = (desca != null ? desca.Description : ""); Enabled = (bool)property.GetValue(config); }
public void Initialize_FromApplicationConfig_From_Application_Configuration() { var configuration = new FeatureConfiguration(); configuration.Initialize(x => x.FromApplicationConfig()); Assert.IsNotNull(configuration.Get("testSimpleEnabled")); Assert.IsNotNull(configuration.Get("testSimpleDisabled")); }
public async Task GivenEnableExtendedQueryTagsIsDisabled_WhenGetExtendedQueryTagsIsCalledMultipleTimes_ThenExtendedQueryTagStoreShouldNotBeCalled() { FeatureConfiguration featureConfiguration = new FeatureConfiguration() { EnableExtendedQueryTags = false }; IQueryTagService indexableDicomTagService = new QueryTagService(_extendedQueryTagStore, Options.Create(featureConfiguration)); await indexableDicomTagService.GetQueryTagsAsync(); await _extendedQueryTagStore.DidNotReceiveWithAnyArgs().GetExtendedQueryTagsAsync(default, default, default);
public ConditionalCreatePostConfigureOptions( IOptions <FeatureConfiguration> features, IConfiguredConformanceProvider configuredConformanceProvider) { EnsureArg.IsNotNull(features, nameof(features)); EnsureArg.IsNotNull(configuredConformanceProvider, nameof(configuredConformanceProvider)); _features = features.Value; _configuredConformanceProvider = configuredConformanceProvider; }
static void PrintFeatureConfig(FeatureConfiguration config) { Console.WriteLine("[0x{0:X8} / {0}]", config.FeatureId); Console.WriteLine("Group: {0}", config.Group); Console.WriteLine("EnabledState: {0} ({1})", config.EnabledState, (int)config.EnabledState); Console.WriteLine("EnabledStateOptions: {0}", config.EnabledStateOptions); Console.WriteLine("Variant: {0}", config.Variant); Console.WriteLine("VariantPayloadKind: {0}", config.VariantPayloadKind); Console.WriteLine("VariantPayload: {0:x}", config.VariantPayload); }
private IlrMessageTask NewService( IMessageProvider messageProvider = null, IReferenceDataPopulationService referenceDataPopulationService = null, IEdrsApiService edrsApiService = null, IFilePersister filePersister = null, ILogger logger = null, FeatureConfiguration featureConfiguration = null) { return(new IlrMessageTask(messageProvider, referenceDataPopulationService, edrsApiService, filePersister, featureConfiguration, logger)); }
public static void ConfigureAddedServices(this IMvcBuilder mvc, string controllerNameSpace, Action <IFeatureConfiguration> configure) { var conf = new FeatureConfiguration(); configure.Invoke(conf); mvc.ConfigureApplicationPartManager(d => { d.FeatureProviders.Add(new CustomizableFeatureProvider(controllerNameSpace, conf)); }); }
public void Add_Adds_Feature_By_Name() { var configuration = new FeatureConfiguration(); var expected = new BooleanToggle(TestFeatureName, true); configuration.Add(expected); var actual = configuration.Get(TestFeatureName); Assert.AreSame(expected, actual); }
public void LoadConfiguration() { try { _config = _configurationReader.LoadConfiguration <FeatureConfiguration>(FeatureConfiguration.SectionName); } catch (Exception e) { throw new Exception("Unable to load feature toggle configuration. See inner exception for more details", e); } }
private static void ConfigureBus(IBusControl bus, Container container, FeatureConfiguration <OrderMessageConsumptionFeatureOptions> featureConfiguration) { var queueName = featureConfiguration.FeatureOptions.QueueName; bus.ConnectReceiveEndpoint(queueName, configurator => { configurator.Consumer <OrderAddedConsumer>(container); //configurator.UseMessageRetry(r => r.Immediate(5)); }); }
public void Can_Find_Feature_Toggle_By_Name() { const string toggleName = "testName"; var toggle = new BooleanToggle(toggleName, true); var featureConfiguration = new FeatureConfiguration { toggle }; var locator = new LocateByNameStrategy(featureConfiguration, toggleName); Assert.AreSame(toggle, locator.Locate()); }
public async Task GivenEnableExtendedQueryTagsIsDisabled_WhenGetExtendedQueryTagsIsCalledMultipleTimes_ThenExtendedQueryTagStoreShouldNotBeCalled() { FeatureConfiguration featureConfiguration = new FeatureConfiguration() { EnableExtendedQueryTags = false }; IQueryTagService indexableDicomTagService = new QueryTagService(_extendedQueryTagStore, Options.Create(featureConfiguration)); await indexableDicomTagService.GetQueryTagsAsync(); await _extendedQueryTagStore.DidNotReceive().GetExtendedQueryTagsAsync(Arg.Any <string>(), Arg.Any <CancellationToken>()); }
public void Add_Verifies_And_Freezes_Toggle() { var configuration = new FeatureConfiguration(); var toggle = new Mock <IFeatureToggle>(); toggle.Setup(x => x.AssertConfigurationIsValid()); toggle.Setup(x => x.Freeze()); toggle.Setup(x => x.Name).Returns("name"); configuration.Add(toggle.Object); toggle.VerifyAll(); }
public override void ConfigureServices(IServiceCollection services) { base.ConfigureServices(services); FeatureConfiguration configuration = new FeatureConfiguration() { SupportsAnonymizedExport = true, }; IOptions <FeatureConfiguration> options = Options.Create <FeatureConfiguration>(configuration); services.Replace(new ServiceDescriptor(typeof(IOptions <FeatureConfiguration>), options)); }
public void Count_Represents_Number_Of_Configured_Items() { var configuration = new FeatureConfiguration(); Assert.AreEqual(0, configuration.Count); configuration.Add(new BooleanToggle("f1", true)); Assert.AreEqual(1, configuration.Count); configuration.Add(new BooleanToggle("f2", true)); Assert.AreEqual(2, configuration.Count); }
public OperationDefinitionController( IMediator mediator, IOptions <OperationsConfiguration> operationsConfig, IOptions <FeatureConfiguration> featureConfig) { EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(operationsConfig?.Value, nameof(operationsConfig)); EnsureArg.IsNotNull(featureConfig?.Value, nameof(featureConfig)); _mediator = mediator; _operationConfiguration = operationsConfig.Value; _featureConfiguration = featureConfig.Value; }
public OperationsCapabilityProvider( IOptions <OperationsConfiguration> operationConfiguration, IOptions <FeatureConfiguration> featureConfiguration, IUrlResolver urlResolver) { EnsureArg.IsNotNull(operationConfiguration?.Value, nameof(operationConfiguration)); EnsureArg.IsNotNull(featureConfiguration?.Value, nameof(featureConfiguration)); EnsureArg.IsNotNull(urlResolver, nameof(urlResolver)); _operationConfiguration = operationConfiguration.Value; _featureConfiguration = featureConfiguration.Value; _urlResolver = urlResolver; }
public void Initialize_From_Source_Handles_Nulls_From_Custom_Readers() { var reader = new Mock <IConfigurationReader>(); reader.Setup(x => x.GetFeatures()).Returns((IEnumerable <IFeatureToggle>)null); var configuration = new FeatureConfiguration(); configuration.Initialize(x => x.FromSource(reader.Object)); Assert.AreEqual(0, configuration.Count); reader.VerifyAll(); }
public void GivenARequest_WhenValidationIsNotSupported_ThenAnExceptionIsReturned() { var featureConfiguration = new FeatureConfiguration() { SupportsValidate = false, }; var filter = new ValidationQueryFilterAndParameterParserAttribute(Options.Create(featureConfiguration)); var context = CreateContext(); var exception = Assert.Throws <OperationNotImplementedException>(() => filter.OnActionExecuting(context)); Assert.Equal("$validate is not a supported endpoint.", exception.Message); }
public void Add_Replaces_Feature_With_Name() { var configuration = new FeatureConfiguration(); var original = new BooleanToggle(TestFeatureName, false); var expected = new BooleanToggle(TestFeatureName, true); configuration.Add(original); configuration.Add(expected); var actual = configuration.Get(TestFeatureName); Assert.AreSame(expected, actual); }
public XmlFormatterConfiguration( IOptions <FeatureConfiguration> featureConfiguration, IConfiguredConformanceProvider configuredConformanceProvider, IEnumerable <TextInputFormatter> inputFormatters, IEnumerable <TextOutputFormatter> outputFormatters) { EnsureArg.IsNotNull(featureConfiguration, nameof(featureConfiguration)); EnsureArg.IsNotNull(featureConfiguration.Value, nameof(featureConfiguration)); EnsureArg.IsNotNull(inputFormatters, nameof(inputFormatters)); EnsureArg.IsNotNull(outputFormatters, nameof(outputFormatters)); _featureConfiguration = featureConfiguration.Value; _configuredConformanceProvider = configuredConformanceProvider; }
private static ValidateController GetController(bool enableValidate) { var featureConfiguration = new FeatureConfiguration { SupportsValidate = enableValidate, }; IOptions <FeatureConfiguration> optionsFeatureConfiguration = Substitute.For <IOptions <FeatureConfiguration> >(); optionsFeatureConfiguration.Value.Returns(featureConfiguration); IMediator mediator = Substitute.For <IMediator>(); return(new ValidateController(mediator, optionsFeatureConfiguration)); }
private Features(IWindsorContainer container, FeatureConfiguration featureConfiguration) { _container = container; var featureHandlerSelector = new FeatureHandlerSelector(_container.Kernel); featureHandlerSelector.AddFeatureSpecConfig(featureConfiguration); _container.Kernel.AddHandlerSelector(featureHandlerSelector); foreach (var featureSpecType in featureConfiguration.ConfigMap /* TODO: .Where(kvp => typeof(IFeatureMap).IsAssignableFrom(kvp.Value))*/) { _container.Kernel.Register(Component.For(featureSpecType.Value).ImplementedBy(featureSpecType.Value)); } }
public ValidatePostConfigureOptions( IOptions <FeatureConfiguration> features, IConfiguredConformanceProvider configuredConformanceProvider, IModelInfoProvider modelInfoProvider) { EnsureArg.IsNotNull(features, nameof(features)); EnsureArg.IsNotNull(features.Value, nameof(features)); EnsureArg.IsNotNull(configuredConformanceProvider, nameof(configuredConformanceProvider)); EnsureArg.IsNotNull(modelInfoProvider, nameof(modelInfoProvider)); _features = features.Value; _configuredConformanceProvider = configuredConformanceProvider; _modelInfoProvider = modelInfoProvider; }
public string BuildMenu() { var featureConfig = new FeatureConfiguration().InitialiseFeatureConfigFromXml(); var strBuilder = new StringBuilder(); var orderedGroups = featureConfig.MenuGroups.OrderBy(mg => mg.Position); foreach (var orderedGroup in orderedGroups) { var featuresInThisGroup = GetMenuItemsThatBelongInThisGroup(featureConfig.Features, orderedGroup.Name); var builder = new StringBuilder(); foreach (var menuItem in featuresInThisGroup) { builder.AppendLine(VisitMenuItem(menuItem)); } var group = VisitMenuGroup(orderedGroup); strBuilder.AppendFormat(group, builder); } return string.Format(MenuWrapFormatString, strBuilder); }
public void Add_Throws_For_Null_Toggles() { var configuration = new FeatureConfiguration(); Assert.Throws<ArgumentNullException>(() => configuration.Add(null)); }
public void Can_Enumerate_Over_Feature_Toggles_Via_Base_IEnumerable_Interface() { var configuration = new FeatureConfiguration(); var f1 = new BooleanToggle("f1", true); configuration.Add(f1); var f2 = new BooleanToggle("f2", true); configuration.Add(f2); IEnumerable baseConfiguration = configuration; var enumerator = baseConfiguration.GetEnumerator(); Assert.IsTrue(enumerator.MoveNext()); }
public void WhatDoIHave_Returns_Diagnostic_String_On_Feature_Toggle_Instances() { var configuration = new FeatureConfiguration(); var f1 = new BooleanToggle("f1", true); configuration.Add(f1); var f2 = new BooleanToggle("f2", false); configuration.Add(f2); string diagnostics = configuration.WhatDoIHave(); StringAssert.Contains("f1", diagnostics); StringAssert.Contains(bool.TrueString, diagnostics); StringAssert.Contains("f2", diagnostics); StringAssert.Contains(bool.FalseString, diagnostics); }
public void Get_Returns_Null_If_Toggle_Not_Found() { var configuration = new FeatureConfiguration(); Assert.IsNull(configuration.Get("nonExistentName")); }
public void Initialize_Throws_For_Null_Configuration_Expression() { var configuration = new FeatureConfiguration(); Assert.Throws<ArgumentNullException>(() => configuration.Initialize(null)); }
public void AddFeatureSpecConfig(FeatureConfiguration featureConfiguration) { _featureSpecs = featureConfiguration.ConfigMap; }
public void Initialize_From_Source_Initializes_From_Custom_Reader() { var reader = new Mock<IConfigurationReader>(); var feature1 = new BooleanToggle("f1", true); var feature2 = new BooleanToggle("f2", true); var features = new[] { feature1, feature2 }; reader.Setup(x => x.GetFeatures()).Returns(features); var configuration = new FeatureConfiguration(); configuration.Initialize(x => x.FromSource(reader.Object)); Assert.AreSame(feature1, configuration.Get("f1")); Assert.AreSame(feature2, configuration.Get("f2")); reader.VerifyAll(); }
public void Initialize_From_Source_Throws_For_Null_Reader() { var configuration = new FeatureConfiguration(); Assert.Throws<ArgumentNullException>(() => configuration.Initialize(x => x.FromSource(null))); }
public void Initialize_From_Source_Handles_Nulls_From_Custom_Readers() { var reader = new Mock<IConfigurationReader>(); reader.Setup(x => x.GetFeatures()).Returns((IEnumerable<IFeatureToggle>)null); var configuration = new FeatureConfiguration(); configuration.Initialize(x => x.FromSource(reader.Object)); Assert.AreEqual(0, configuration.Count); reader.VerifyAll(); }
public void Get_Throws_For_Null_Names() { var configuration = new FeatureConfiguration(); Assert.Throws<ArgumentNullException>(() => configuration.Get(null)); }
public void Add_Verifies_And_Freezes_Toggle() { var configuration = new FeatureConfiguration(); var toggle = new Mock<IFeatureToggle>(); toggle.Setup(x => x.AssertConfigurationIsValid()); toggle.Setup(x => x.Freeze()); toggle.Setup(x => x.Name).Returns("name"); configuration.Add(toggle.Object); toggle.VerifyAll(); }
public void IsEnabled_Returns_False_For_Non_Existent_Feature() { var configuration = new FeatureConfiguration(); Assert.IsFalse(configuration.IsEnabled("nonExistentName")); }
public void Can_Enumerate_Over_Feature_Toggles() { var configuration = new FeatureConfiguration(); var f1 = new BooleanToggle("f1", true); configuration.Add(f1); var f2 = new BooleanToggle("f2", true); configuration.Add(f2); Assert.IsTrue(configuration.Any(x => x == f1)); Assert.IsTrue(configuration.Any(x => x == f2)); }
public void IsEnabled_Returns_True_For_Enabled_Features() { var configuration = new FeatureConfiguration(); const bool expected = true; var feature = new BooleanToggle(TestFeatureName, expected); configuration.Add(feature); var actual = configuration.IsEnabled(TestFeatureName); Assert.AreEqual(expected, actual); }
public Features WithFeatures(Action<FeatureConfiguration> featureSpecConfig) { var config = new FeatureConfiguration(); featureSpecConfig(config); return new Features(_container, config); }
public void Read_Throws_CircularDependecy_Exception_For_Circular_Dependencies() { var reader = new ApplicationConfigurationReader(() => new DummyToggleConfig { Toggles = new FeatureToggleCollection { new ToggleConfig { Name = "a", Dependencies = "b,d" }, new ToggleConfig { Name = "b" }, new ToggleConfig { Name = "c" }, new ToggleConfig { Name = "d", Dependencies = "b, a" }, } }); var configuration = new FeatureConfiguration(); var features = reader.GetFeatures().ToList(); Assert.Throws<CircularDependencyException>(() => { foreach (var feature in features) { configuration.Add(feature); } }); }
public void Clear_Clears_Features_From_Configuration() { var configuration = new FeatureConfiguration(); const bool expected = false; var feature = new BooleanToggle(TestFeatureName, expected); configuration.Add(feature); configuration.Clear(); Assert.IsNull(configuration.Get(TestFeatureName)); Assert.AreEqual(0, configuration.Count); }