Esempio n. 1
0
        public async Task CreateAsync_logs_off_with_the_correct_type_when_feature_is_off()
        {
            var evaluator = Substitute.For <IFeatureEvaluator>();
            var feature   = new SimpleTestFeature(evaluator);
            var logger    = Logger.For <FeatureSelector <SimpleTestFeature, NewGetSomething, OldGetSomething, IGetSomething> >();
            var selector  = new FeatureSelector <SimpleTestFeature, NewGetSomething, OldGetSomething, IGetSomething>(
                feature,
                () => new NewGetSomething(),
                () => new OldGetSomething(),
                logger);

            evaluator.IsOnAsync(Arg.Any <string>()).Returns(false);

            var getter = await selector.CreateAsync();

            logger.Received().LogInformation(s => s.Contains("OldGetSomething") && s.Contains("Test Feature") && s.Contains("off"));
        }
Esempio n. 2
0
        public async Task CreateAsync_creates_the_correct_type_when_feature_is_off()
        {
            var evaluator = Substitute.For <IFeatureEvaluator>();
            var feature   = new SimpleTestFeature(evaluator);
            var selector  = new FeatureSelector <SimpleTestFeature, NewGetSomething, OldGetSomething, IGetSomething>(
                feature,
                () => new NewGetSomething(),
                () => new OldGetSomething(),
                null);

            evaluator.IsOnAsync(Arg.Any <string>()).Returns(false);

            var getter = await selector.CreateAsync();

            var result = getter.GetSomething();

            getter.Should().BeOfType <OldGetSomething>();
            result.Should().Be("Old");
        }