public void IsEnabledCallsAllToggles([Frozen] IFeatureToggleProvider toggleProvider, IFeature feature,
            Fixture fixture, FeatureContext sut)
        {
            var featureToggles = fixture.CreateMany<Fake<IFeatureToggle>>().ToList();
            foreach (Fake<IFeatureToggle> fake in featureToggles)
            {
                fake.CallsTo(ft => ft.IsEnabled(feature))
                    .Returns(null);
            }
            var finalTogle = A.Fake<Fake<IFeatureToggle>>();
            finalTogle.CallsTo(ft => ft.IsEnabled(feature))
                .Returns(true);
            featureToggles.Add(finalTogle);

            A.CallTo(() => toggleProvider.GetFeatureToggles())
                .Returns(featureToggles.Select(f => f.FakedObject));

            sut.IsEnabled(feature);

            foreach (Fake<IFeatureToggle> fake in featureToggles)
            {
                fake.CallsTo(ft => ft.IsEnabled(feature))
                    .MustHaveHappened();
            }
        }
Example #2
0
 public void Initialize()
 {
     featureContext = new FeatureContext(null);
     scenarioContext = new ScenarioContext(featureContext, null);
     stepContext = new StepContext(featureContext, scenarioContext);
     sut = new ContextHandler(featureContext, scenarioContext, stepContext);
 }
        public void IsEnabledCallsGetsFeatureToggles([Frozen] IFeatureToggleProvider toggleProvider, IFeature feature,
            FeatureContext sut)
        {
            Ignore.Exception<FeatureStateNotFoundException, bool>(() => sut.IsEnabled(feature));

            A.CallTo(() => toggleProvider.GetFeatureToggles())
                .MustHaveHappened();
        }
        public void IsEnabledCallsIsEnabledOnToggle([Frozen] IFeatureToggleProvider toggleProvider, IFeature feature,
            IFeatureToggle featureToggle, bool expected, FeatureContext sut)
        {
            A.CallTo(() => featureToggle.IsEnabled(feature))
                .Returns(expected);
            A.CallTo(() => toggleProvider.GetFeatureToggles())
                .Returns(new[] {featureToggle});

            bool result = sut.IsEnabled(feature);

            A.CallTo(() => featureToggle.IsEnabled(feature))
                .MustHaveHappened();
            Assert.Equal(expected, result);
        }
Example #5
0
 public void WarningFeature(GameStateType state, FeatureContext source, FeatureContext target)
 {
     if (state == GameStateType.Race)
     {
         if (source.tire != target.tire)
         {
             noteTire.text = target.tire.ToString();
             noteTire.color = Color.red;
         }
         if (source.brake != target.brake)
         {
             noteBrake.text = target.brake.ToString();
             noteBrake.color = Color.red;
         }
         if (source.gearbox != target.gearbox)
         {
             noteGearbox.text = target.gearbox.ToString();
             noteGearbox.color = Color.red;
         }
         if (source.body != target.body)
         {
             noteBody.text = target.body.ToString();
             noteBody.color = Color.red;
         }
         if (source.motor != target.motor)
         {
             noteMotor.text = target.motor.ToString();
             noteMotor.color = Color.red;
         }
         if (source.handling != target.handling)
         {
             noteHandling.text = target.handling.ToString();
             noteHandling.color = Color.red;
         }
     }
     else if (state == GameStateType.Qualification)
     {
         if (source.outOfBend != target.outOfBend)
         {
             notePenalty.text = target.outOfBend.ToString();
             notePenalty.color = Color.red;
         }
     }
 }
Example #6
0
        public void UpdateFeature(GameStateType state, FeatureContext feature, int bendStop, int maxBendStop)
        {
            var currentBendStop = bendStop;
            if (bendStop > maxBendStop)
            {
                currentBendStop = maxBendStop;
            }

            if (state == GameStateType.Race)
            {
                panelRaceFeature.gameObject.SetActive(true);
                panelQualificationFeature.gameObject.SetActive(false);
                noteTire.text = feature.tire.ToString();
                noteTire.color = Color.black;

                noteBrake.text = feature.brake.ToString();
                noteBrake.color = Color.black;

                noteGearbox.text = feature.gearbox.ToString();
                noteGearbox.color = Color.black;

                noteBody.text = feature.body.ToString();
                noteBody.color = Color.black;

                noteMotor.text = feature.motor.ToString();
                noteMotor.color = Color.black;

                noteHandling.text = feature.handling.ToString();
                noteHandling.color = Color.black;

                noteBend.text = string.Format("{0}/{1}", currentBendStop, maxBendStop);
            }
            else if (state == GameStateType.Qualification)
            {
                panelRaceFeature.gameObject.SetActive(false);
                panelQualificationFeature.gameObject.SetActive(true);

                notePenalty.text = feature.outOfBend.ToString();
                notePenalty.color = Color.black;

                noteQualificationBend.text = string.Format("{0}/{1}", currentBendStop, maxBendStop);
            }
        }
 public AGPublicExportPage(IWebDriver driver, FeatureContext featureContext) : base(driver, featureContext)
 {
 }
 public static void CompleteFeatureContainerSetup(FeatureContext featureContext)
 {
     CompleteContainerSetup(featureContext);
 }
 public ProvidersRequiringResubmissionSteps(FeatureContext context) : base(context)
 {
 }
 // public methods
 public bool IsMet(FeatureContext context)
 {
     return context.ServerInstanceType == _instanceType;
 }
        public static void InitializeContainer(FeatureContext featureContext)
        {
            ContainerBindings.ConfigureServices(
                featureContext,
                services =>
            {
                IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
                                                             .AddEnvironmentVariables()
                                                             .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true);

                IConfiguration root = configurationBuilder.Build();

                services.AddSingleton(root);

                services.AddLogging();

                services.AddInMemoryTenantProvider();

                services.AddJsonNetSerializerSettingsProvider();
                services.AddJsonNetPropertyBag();
                services.AddJsonNetCultureInfoConverter();
                services.AddJsonNetDateTimeOffsetToIso8601AndUnixTimeConverter();
                services.AddSingleton <JsonConverter>(new StringEnumConverter(true));
                services.AddCosmosClientBuilderWithNewtonsoftJsonIntegration();

                // Even non-cosmos tests depend on ICosmosContainerSourceWithTenantLegacyTransition
                // because the various 'data catalog' parts of the test use a Cosmos DB.
                services.AddTenantCosmosContainerFactory();
                services.AddCosmosContainerV2ToV3Transition();

                services.AddInMemoryWorkflowTriggerQueue();
                services.AddInMemoryLeasing();

                services.RegisterCoreWorkflowContentTypes();
                services.AddTenantedWorkflowEngineFactory();

                if (featureContext.FeatureInfo.Tags.Any(t => t == "useCosmosStores"))
                {
                    services.AddTenantedAzureCosmosWorkflowStore();
                    services.AddTenantedAzureCosmosWorkflowInstanceStore();
                }
                else if (featureContext.FeatureInfo.Tags.Any(t => t == "useSqlStores"))
                {
                    services.AddTenantedSqlWorkflowStore();
                    services.AddTenantedSqlWorkflowInstanceStore();
                }
                else if (featureContext.FeatureInfo.Tags.Any(t => t == "useAzureBlobStore"))
                {
                    services.AddTenantedBlobWorkflowStore();

                    // We don't yet have a blob implementation of the instance store.
                    services.AddSingleton <ITenantedWorkflowInstanceStoreFactory, FakeTenantedWorkflowInstanceStoreFactory>();
                }

                services.AddContent(factory => factory.RegisterTestContentTypes());

                services.AddSingleton <DataCatalogItemRepositoryFactory>();

                // Faking out the service identity is slightly awkward because in some cases we need
                // it to work for real (so we can read Azure Key Vault secrets in configuration)
                // but some tests need to provide fake results. So we spin up a second container
                // with a real service identity, and put a wrapper around that into the container
                // that everything is really using.
                ServiceCollection containerForRealTokenProvider = new();
                string azureServicesAuthConnectionString        = root["AzureServicesAuthConnectionString"];
                containerForRealTokenProvider
                .AddServiceIdentityAzureTokenCredentialSourceFromLegacyConnectionString(azureServicesAuthConnectionString);
                IServiceProvider spForRealTokenProvider = containerForRealTokenProvider.BuildServiceProvider();
                IServiceIdentityAzureTokenCredentialSource realTokenProvider = spForRealTokenProvider.GetRequiredService <IServiceIdentityAzureTokenCredentialSource>();

                // We do this to get the IServiceIdentityAccessTokenSource, because there isn't an easy way to get that
                // but our adapter as the IServiceIdentityAzureTokenCredentialSource.
                services.AddServiceIdentityAzureTokenCredentialSourceFromLegacyConnectionString(azureServicesAuthConnectionString);

                // And now we replace the IServiceIdentityAzureTokenCredentialSource with our adapter.
                services.AddSingleton <IServiceIdentityAzureTokenCredentialSource>(new FakeServiceIdentityTokenSource(realTokenProvider));
            });
        }
 public static void BeforeFeature(FeatureContext featureContext)
 {
     //Create dynamic feature name
     featureName = extent.CreateTest <Feature>(featureContext.FeatureInfo.Title);
 }
Example #13
0
 public ContextHandler(FeatureContext featureContext, ScenarioContext scenarioContext, StepContext stepContext)
 {
     this.featureContext  = featureContext;
     this.scenarioContext = scenarioContext;
     this.stepContext     = stepContext;
 }
Example #14
0
 public static void DisposeFeature(FeatureContext feature)
 => DisposeAll(feature);
Example #15
0
 public void IsEnabledThrowsWhenGivenNullFeature(FeatureContext sut)
 {
     Assert.Throws<ArgumentNullException>(() => sut.IsEnabled(feature: null));
 }
Example #16
0
 public ScenarioHooks(FeatureContext featureContext, ScenarioContext scenarioContext)
 {
     _featureContext  = featureContext;
     _scenarioContext = scenarioContext;
 }
Example #17
0
 protected override void SetupContextTags()
 {
     var f = new FeatureContext(null, new[] { "tag1" });
     Tiny.TinyIoCContainer.Current.Register(f);
     var c = new ScenarioContext(f, null, new[] { "tag2", "tag5" });
     Tiny.TinyIoCContainer.Current.Register(c);
 }
Example #18
0
 private FeatureContext ComputeUseBrake(FeatureContext features, int de, bool isStandWay, int nbCase)
 {
     FeatureContext result = features.Clone();
     if (ContextEngine.Instance.gameContext.state == GameStateType.Race && !isStandWay)
     {
         int difDe = de - nbCase;
         if (difDe >= 6)
         {
             result.brake = features.brake - 3;
             result.tire = features.tire - 3;
         }
         else if (difDe == 5)
         {
             result.brake = features.brake - 3;
             result.tire = features.tire - 2;
         }
         else if (difDe == 4)
         {
             result.brake = features.brake - 3;
             result.tire = features.tire - 1;
         }
         else if (difDe == 3)
         {
             result.brake = features.brake - 3;
         }
         else if (difDe == 2)
         {
             result.brake = features.brake - 2;
         }
         else if (difDe == 1)
         {
             result.brake = features.brake - 1;
         }
     }
     return result;
 }
Example #19
0
 private FeatureContext ComputeOutOfBend(FeatureContext features, int nbOut)
 {
     if (nbOut > 0)
     {
         FeatureContext result = features.Clone();
         if (ContextEngine.Instance.gameContext.state == GameStateType.Race)
         {
             result.tire = features.tire - nbOut;
         }
         else if (ContextEngine.Instance.gameContext.state == GameStateType.Qualification)
         {
             result.outOfBend += nbOut;
         }
         return result;
     }
     else
     {
         return features;
     }
 }
Example #20
0
        public void IsEnabledUsesFirstToggleProviderResult([Frozen] IFeatureToggleProvider toggleProvider,
            IFeature feature, IFeatureToggle skippedToggle, IFeatureToggle enabledToggle, IFeatureToggle endToggle,
            bool expected, FeatureContext sut)
        {
            A.CallTo(() => enabledToggle.IsEnabled(feature))
                .Returns(expected);
            A.CallTo(() => toggleProvider.GetFeatureToggles())
                .Returns(new[] {skippedToggle, enabledToggle, endToggle});

            bool result = sut.IsEnabled(feature);

            Assert.Equal(expected, result);
            A.CallTo(() => endToggle.IsEnabled(feature))
                .MustNotHaveHappened();
        }
Example #21
0
        public void IsEnabledThrowsWhenNoToggleProviderHasState(IFeature feature, FeatureContext sut)
        {
            var exception = Assert.Throws<FeatureStateNotFoundException>(() => sut.IsEnabled(feature));

            Assert.Same(feature, exception.Feature);
        }
Example #22
0
 public ContextHandler(FeatureContext featureContext, ScenarioContext scenarioContext, StepContext stepContext)
 {
     this.featureContext = featureContext;
     this.scenarioContext = scenarioContext;
     this.stepContext = stepContext;
 }
 public static void TeardownContainer(FeatureContext featureContext)
 {
     featureContext.RunAndStoreExceptions(
         () => DisposeServiceProvider(featureContext));
 }
        public static void BeforeFeature(FeatureContext context)
        {
            var featureTest = extent.CreateTest <Feature>(context.FeatureInfo.Title);

            context.FeatureContainer.RegisterInstanceAs(featureTest);
        }
 /// <summary>
 /// Gets the <see cref="IServiceProvider"/> for the specified feature context.
 /// </summary>
 /// <param name="featureContext">The SpecFlow context.</param>
 /// <returns>The service provider.</returns>
 /// <remarks>
 /// You can call this either during execution of steps, or in a <c>BeforeFeature</c> binding with
 /// an <c>Order</c> greater than or equal to <see cref="ContainerBeforeFeatureOrder.ServiceProviderAvailable"/>.
 /// </remarks>
 public static IServiceProvider GetServiceProvider(FeatureContext featureContext) => GetServiceProvider(
     featureContext,
     $"This method must be called either during Step execution, or in a BeforeFeature bindings with an Order >= {nameof(ContainerBeforeFeatureOrder)}.{nameof(ContainerBeforeFeatureOrder.ServiceProviderAvailable)}");
Example #26
0
 public void OutputScenario(FeatureContext featureContext, ScenarioContext scenarioContext)
 {
     LogHelper.Info(" " + "--------[BeforeScenario]---------");
     LogHelper.Info(" " + $"Feature: {featureContext.FeatureInfo.Title}");
     LogHelper.Info(" " + $"Scenario: {scenarioContext.ScenarioInfo.Title}");
 }
 public static void StartFeatureContainerSetup(FeatureContext featureContext)
 {
     CreateServiceCollection(featureContext);
 }
Example #28
0
 public static void ResetFeature(FeatureContext feature)
 => ResetAll(feature);
 public static string GetFullName(TestContext tc, ScenarioContext sc, FeatureContext fc)
 {
     return
         ($"{sc.TestContext().FullyQualifiedTestClassName}.{fc.FeatureInfo.Title}.{sc.ScenarioInfo.Title}");
 }
Example #30
0
 public HookInitialize(ParallelConfig parallelConfig, FeatureContext featureContext, ScenarioContext scenarioContext) : base(parallelConfig)
 {
     _parallelConfig  = parallelConfig;
     _featureContext  = featureContext;
     _scenarioContext = scenarioContext;
 }
 public ITestDataProvider GetTestDataProvider(FeatureInfo fi, ScenarioInfo si, FeatureContext fc, ScenarioContext sc)
 {
     return(new GhprMSTestSpecFlowTestDataProvider(sc.TestContext(), sc, fc));
 }
Example #32
0
 public ObjectSteps(FeatureContext featureContext, ScenarioContext context)
 {
     this.context        = context;
     this.featureContext = featureContext;
 }
        public TestRunDto GetTestRunOnScenarioStart(ITestRunner runner, FeatureInfo fi, ScenarioInfo si, FeatureContext fc, ScenarioContext sc)
        {
            var tc = sc.TestContext();

            ScreenHelper   = new GhprMSTestSpecFlowScreenHelper();
            TestDataHelper = new GhprMSTestSpecFlowTestDataHelper(tc, sc, fc);

            var fullName    = $"{tc?.FullyQualifiedTestClassName}.{fi.Title}.{si.Title}";
            var name        = si.Title;
            var nameForGuid = GetFullNameForGuid(tc, sc, fc);
            var guid        = nameForGuid.ToMd5HashGuid().ToString();
            var testRun     = new TestRunDto(guid, name, fullName)
            {
                Categories = si.Tags,
                TestInfo   =
                {
                    Start = DateTime.Now
                }
            };

            _logger.Debug($"TestRunDto created in GetTestRunOnScenarioStart: FullName = {fullName}, FullNameForGuid = {nameForGuid}");
            return(testRun);
        }
Example #34
0
 public BookingSteps(GlobalContext globalContext)
 {
     _gContext      = globalContext;
     _context       = globalContext.FeatureContext;
     _apiController = new ApiController();
 }
        public TestRunDto UpdateTestRunOnScenarioEnd(TestRunDto tr, Exception testError, TestOutputDto testOutputDto, FeatureContext fc, ScenarioContext sc)
        {
            var tc          = sc.ScenarioContainer.Resolve <TestContext>();
            var nameForGuid = GetFullNameForGuid(tc, sc, fc);
            var guid        = nameForGuid.ToMd5HashGuid().ToString();

            tr.TestInfo.Guid  = Guid.Parse(guid);
            tr.FullName       = GetFullName(tc, sc, fc);
            tr.Result         = testError == null ? "Passed" : (testError is AssertFailedException ? "Failed" : "Error");
            tr.TestMessage    = testError?.Message ?? "";
            tr.TestStackTrace = testError?.StackTrace ?? "";
            tr.TestData.AddRange(TestDataHelper.GetTestData());
            return(tr);
        }
Example #36
0
 public ContributorsTestSetup(IObjectContainer objectContainer, FeatureContext featureContext)
     : base(objectContainer, featureContext)
 {
 }
Example #37
0
 public SeleniumExecutor(IObjectContainer objectContainer, ScenarioContext scenarioContext, FeatureContext featureContext)
     : base(_appSettings)
 {
     this.objectContainer = objectContainer;
     this.scenarioContext = scenarioContext;
     this.featureContext  = featureContext;
 }
Example #38
0
 public Hooks(BrowserBase browserBase, ScenarioContext scenarioContext, FeatureContext featureContext)
 {
     _featureContext  = featureContext;
     _scenarioContext = scenarioContext;
     _browserBase     = browserBase;
 }
 public static string GetNextPictureName(FeatureContext featureContext, ScenarioContext scenarioContext)
 {
     return(GetNextSupportingInfoFileName(featureContext, scenarioContext, EmuShotPrefix, "png"));
 }
Example #40
0
 public DynamicPropertyBindings(ScenarioContext scenarioContext, FeatureContext featureContext)
     : base(scenarioContext, featureContext)
 {
 }
 public void IsEnabledThrowsWhenGivenNullFeature(FeatureContext sut)
 {
     Assert.Throws <ArgumentNullException>(() => sut.IsEnabled(feature: null));
 }
 // public methods
 public bool IsMet(FeatureContext context)
 {
     return !_dependency.IsMet(context);
 }
        public void IsEnabledCallsIsEnabledOnToggle([Frozen] IFeatureToggleProvider toggleProvider, IFeature feature,
                                                    IFeatureToggle featureToggle, bool expected, FeatureContext sut)
        {
            A.CallTo(() => featureToggle.IsEnabled(feature))
            .Returns(expected);
            A.CallTo(() => toggleProvider.GetFeatureToggles())
            .Returns(new[] { featureToggle });

            bool result = sut.IsEnabled(feature);

            A.CallTo(() => featureToggle.IsEnabled(feature))
            .MustHaveHappened();
            Assert.Equal(expected, result);
        }
Example #44
0
 protected override void SetupContextTags()
 {
     var f = new FeatureContext(null, new string[0]);
     Tiny.TinyIoCContainer.Current.Register(f);
     var c = new ScenarioContext(f, null, new[] { "DontRun" });
     Tiny.TinyIoCContainer.Current.Register(c);
 }
        public void IsEnabledThrowsWhenNoToggleProviderHasState(IFeature feature, FeatureContext sut)
        {
            var exception = Assert.Throws <FeatureStateNotFoundException>(() => sut.IsEnabled(feature));

            Assert.Same(feature, exception.Feature);
        }
Example #46
0
 public PlayerContext()
 {
     features = new FeatureContext();
     turnHistories = new List<HistoryContext>();
 }
Example #47
0
 public NoContainerSteps(FeatureContext featureContext)
 {
     this.featureContext = featureContext;
 }