Пример #1
0
        public IMiruApp Start(ITestConfig config, Action <IServiceCollection> servicesSetup = null)
        {
            _testRunConfig = new TestRunConfig();

            var servicesFromTestConfig = new ServiceCollection();

            config.ConfigureRun(_testRunConfig);

            config.ConfigureTestServices(servicesFromTestConfig);

            var builder = config.GetHostBuilder();

            builder.UseEnvironment("Test");

            builder.ConfigureServices(services =>
            {
                services.AddSingleton(this);

                services.AddSingleton <TestFixture, TestFixture>();

                services.AddSingleton <ISessionStore, MemorySessionStore>();

                services.AddSingleton <IUserSession, TestingUserSession>();

                services.AddSingleton <Faker, Faker>();

                // services.ReplaceSingleton<ILogger>(sp => TestLoggerConfigurations.ForTests(sp.GetService<Storage>()));

                services.AddRange(servicesFromTestConfig);

                // test engine stuff
                services.AddSingleton <TestConfigRunner>();

                services.AddSingleton(_testRunConfig);

                servicesSetup?.Invoke(services);
            });

            var host = builder.Build();

            var sp = host.Services;

            App = sp.GetService <IMiruApp>();

            ExecuteBeforeSuite();

            return(App);
        }
Пример #2
0
        public static void BeforeCase(this TestRunConfig run, Action <TestFixture> action)
        {
            run.BeforeEach((test, _) =>
            {
                if (test.Implements <IManyCasesPerTest>())
                {
                    action(_);
                }
            });

            run.BeforeAll((test, _) =>
            {
                if (test.Implements <IOneCasePerTest>())
                {
                    action(_);
                }
            });
        }
Пример #3
0
        public static void BeforeCaseInNamespace(this TestRunConfig run, string @namespace, Action <TestFixture> action)
        {
            run.BeforeEach((test, _) =>
            {
                if (test.Namespace.Contains($".{@namespace}") && test.Implements <IManyCasesPerTest>())
                {
                    action(_);
                }
            });

            run.BeforeAll((test, _) =>
            {
                if (test.Namespace.Contains($".{@namespace}") && test.Implements <IOneCasePerTest>())
                {
                    action(_);
                }
            });
        }
Пример #4
0
        public static void AfterCase <TDecoration>(this TestRunConfig run, Action <TestFixture> action)
        {
            run.AfterEach((test, _) =>
            {
                if (test.Implements <IManyCasesPerTest>() && test.Implements <TDecoration>())
                {
                    action(_);
                }
            });

            run.AfterAll((test, _) =>
            {
                if (test.Implements <IOneCasePerTest>() && test.Implements <TDecoration>())
                {
                    action(_);
                }
            });
        }
Пример #5
0
 public TestConfigRunner(TestRunConfig testRunConfig, TestFixture testFixture, ILogger <TestConfigRunner> logger)
 {
     _testRunConfig = testRunConfig;
     _testFixture   = testFixture;
     _logger        = logger;
 }