Esempio n. 1
0
 public static IEnumerable <Type> GetRegisteredServices <TForType>(this IMiruApp app)
 {
     return(app.Get <IServiceCollection>()
            .Where(_ => _.ServiceType == typeof(TForType))
            .Select(_ => _.ImplementationType)
            .ToImmutableList());
 }
Esempio n. 2
0
        public static string ConfigYml(this IMiruApp app, MiruSolution solution = null)
        {
            // solution = solution ?? app.Get<Solution>();
            // return solution.GetConfigYml(app.Config.Environment);

            return(string.Empty);
        }
Esempio n. 3
0
 public ConfigShowConsolable(
     IHostEnvironment hostEnvironment,
     IConfiguration configuration,
     IMiruApp app)
 {
     _hostEnvironment = hostEnvironment;
     _configuration   = configuration;
     _app             = app;
 }
        public static IWebHostBuilder UseMiru(this IWebHostBuilder builder, IMiruApp app)
        {
            // var solution = app.Get<Solution>();
            //
            // builder.UseContentRoot(solution.AppDir);
            //
            // builder.ConfigureServices(services =>
            // {
            //     var container = app.Get<IServiceProvider>();
            //     services.AddSingleton(container);
            // });

            return(builder);
        }
Esempio n. 5
0
        public static TResult SendSync <TResult>(this IMiruApp app, IRequest <TResult> message)
        {
            using var scope = app.WithScope();

            var mediator = scope.Get <IMediator>();

            try
            {
                return(mediator.Send(message).Result);
            }
            catch (AggregateException e)
            {
                throw e.InnerException ?? e;
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public static async Task <TResult> SendAsync <TResult>(this IMiruApp app, IRequest <TResult> message)
        {
            using (var scope = app.WithScope())
            {
                var mediator = scope.Get <IMediator>();

                try
                {
                    return(await mediator.Send(message));
                }
                catch (AggregateException e)
                {
                    throw e.InnerException ?? e;
                }
            }
        }
Esempio n. 8
0
        public PageTestFixture(
            IMiruApp app,
            UrlLookup urlLookup,
            PageTestingConfig config,
            RemoteWebDriver driver,
            IStorage storage,
            PageBody browser,
            MiruNavigator navigator) : base(navigator)
        {
            App = app;

            _urlLookup = urlLookup;
            _config    = config;
            _driver    = driver;
            _storage   = storage;
            _browser   = browser;

            _browser.BaseUrl = _config.BaseUrl;

            navigator.ConfigureExceptions(context =>
            {
                var exceptionMessage = $@"{context.FailureMessage.Or(context.OriginalException.Message)}

The url was: 
{Url}
  
A screenshot was taken on the moment of the failure: 
{FailureScreenshot()}

The Page's html has been saved to:
{SaveHtml()}
";

                throw new PageTestException(exceptionMessage, context.OriginalException);
            });
        }
Esempio n. 9
0
 public ScopedServices(IMiruApp app)
 {
     _scope    = app.Get <IServiceProvider>().CreateScope();
     _services = _scope.ServiceProvider;
 }
Esempio n. 10
0
 public static IWebHost BuildForMiru(this IWebHostBuilder builder, IMiruApp app)
 {
     return(builder.UseMiru(app).Build());
 }
Esempio n. 11
0
 public QueueRunConsolable(IMiruApp app)
 {
     _app = app;
 }
Esempio n. 12
0
 public ValidatorFactory(IMiruApp app)
 {
     _app = app;
 }
Esempio n. 13
0
 public CliMiruHost(IMiruApp app, MiruCommandCreator commandCreator, ArgsConfiguration argsConfig)
 {
     _app            = app;
     _commandCreator = commandCreator;
     _argsConfig     = argsConfig;
 }
Esempio n. 14
0
 public CliMiruHost(IMiruApp app, ArgsConfiguration argsConfig)
 {
     _app        = app;
     _argsConfig = argsConfig;
 }
Esempio n. 15
0
 public ConsolableHandler(IMiruApp app)
 {
     _app = app;
 }
Esempio n. 16
0
 public CliMiruHost(IEnumerable <Consolable> commands, ArgsConfiguration argsConfig, IMiruApp app)
 {
     _consolable = commands;
     _argsConfig = argsConfig;
     _app        = app;
 }
Esempio n. 17
0
        public static void WithScope(this IMiruApp app, Action <ScopedServices> action)
        {
            using var scope = app.Get <ScopedServices>();

            action(scope);
        }
Esempio n. 18
0
 public TestFixture(IMiruApp app)
 {
     App = app;
 }
Esempio n. 19
0
 public MiruCommandCreator(IMiruApp app)
 {
     _app = app;
 }
Esempio n. 20
0
 public MiruDbContext(IMiruApp app) : base(app.Get <DbContextOptions>())
 {
     QueryFilterManager.InitilizeGlobalFilter(this);
 }
Esempio n. 21
0
 public static ScopedServices WithScope(this IMiruApp app)
 {
     return(app.Get <ScopedServices>());
 }
Esempio n. 22
0
 public TestingUserSession(IMiruApp app, ICurrentUser currentUser)
 {
     _app         = app;
     _currentUser = currentUser;
 }
Esempio n. 23
0
        public static TReturn WithScope <TReturn>(this IMiruApp app, Func <ScopedServices, TReturn> func)
        {
            using var scope = app.Get <ScopedServices>();

            return(func(scope));
        }
Esempio n. 24
0
 public FooDbContext(IMiruApp app) : base(app)
 {
 }