public async Task ExecuteAtTheEnd(ITestEnvironment testEnv)
 {
     if (DropDbAtTheEnd)
     {
         await db.Database.EnsureDeletedAsync();
     }
 }
Exemplo n.º 2
0
        public static void Init()
        {
            te           = IOC.Resolve <ITestEnvironment>();
            testContext  = IOC.Resolve <ITestContext>();
            testCaseCode = null;
            theHarness   = null;

            logger.Info("MutaGen Api - Init");
        }
Exemplo n.º 3
0
 public TenantAutofacModule(Tenant tenant, IConfiguration applicationConfiguration,
                            ITestEnvironment testEnvironment, IFeatureManager featureManager)
 {
     _tenant = tenant;
     _applicationConfiguration       = applicationConfiguration;
     _testEnvironment                = testEnvironment;
     _featureManager                 = featureManager;
     _autobookProviderApiAccessToken = applicationConfiguration["AutoBooks:AutobookProviderApiAccessToken"];
 }
 public State(ITestEnvironment[] environments, Func<ITestEnvironment, IDisposable> setUp)
 {
     foreach (ITestEnvironment environment in environments)
     {
         IDisposable innerState = setUp(environment);
         if (innerState != null)
             innerStates.Add(innerState);
     }
 }
        public static async Task SampleTest(ITestEnvironment env)
        {
            await using var test = await env.CreateTest();

            var functionality = test.Resolve <IGetUserById>();
            var result        = functionality.Execute(0);

            result.Should().NotBeNull();
            result.Name.Should().Be("Tom");
        }
Exemplo n.º 6
0
        private IEnumerable<ITestDescriptor> CreateTestGraph(ITestEnvironment environment)
        {
            var discovery = environment.DiscoveryService;
              if (discovery == null)
            throw new TestConfigurationException(string.Format("Test session environment {0} should provide discovery service", environment.GetType()));

              var testDescriptors = discovery.CreateTestGraph();
              if (testDescriptors == null)
            throw new TestCompositionException(string.Format("Test session discovery {0} should return empty enumerable instead of null", discovery.GetType()));
              return testDescriptors;
        }
 public static void InsertTestEntities <TEntity, TDbContext>(this ITestEnvironment testEnvironment, IEnumerable <TEntity> entites)
     where TEntity : class
     where TDbContext : DbContext
 {
     using (var serviceScope = testEnvironment.ServiceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
     {
         var dbContext = serviceScope.ServiceProvider.GetService <TDbContext>();
         dbContext.Set <TEntity>().AddRange(entites);
         dbContext.SaveChanges();
     }
 }
        async Task <BlockExecutionResult> IBlock.Execute(ITestEnvironment testEnv)
        {
            if (RecreateDbAtStart)
            {
                await db.Database.EnsureDeletedAsync();

                await db.Database.EnsureCreatedAsync();
            }

            seedProvider.Add <TModel>();
            await seedProvider.Seed();

            return(BlockExecutionResult.EmptyContinue);
        }
Exemplo n.º 9
0
        Task <BlockExecutionResult> IBlock.Execute(ITestEnvironment testEnv)
        {
            var collection = new ServiceCollection();

            foreach (var serviceDescriptor in internalCollection)
            {
                collection.Add(serviceDescriptor);
            }

            var provider = collection.BuildServiceProvider();

            testEnv.SetServiceProvider(provider);

            return(Task.FromResult(BlockExecutionResult.EmptyContinue));
        }
Exemplo n.º 10
0
        Task <BlockExecutionResult> IBlock.Execute(ITestEnvironment testEnv)
        {
            var sc = new ServiceCollection();

            foreach (var serviceDescriptor in internalCollection)
            {
                sc.Add(serviceDescriptor);
            }

            Autofac.Populate(sc);

            var sp = new AutofacServiceProvider(Autofac.Build());

            testEnv.SetServiceProvider(sp);

            return(Task.FromResult(BlockExecutionResult.EmptyContinue));
        }
Exemplo n.º 11
0
 ///// <summary>
 ///// Constructor.
 ///// </summary>
 public TenantDatabaseController(ITenantsRepository tenantsRepository,
                                 ITenantSettingsRepository tenantSettingsRepository,
                                 ITenantSettingsFeatureManager featureManager,
                                 IFeatureManager productFeatureManager,
                                 IFeatureSettingsProvider featureSettingsProvider,
                                 ITestEnvironment testEnvironment,
                                 IConfiguration configuration,
                                 IMapper mapper)
 {
     _tenantsRepository        = tenantsRepository;
     _tenantSettingsRepository = tenantSettingsRepository;
     _featureManager           = featureManager;
     _productFeatureManager    = productFeatureManager;
     _featureSettingsProvider  = featureSettingsProvider;
     _testEnvironment          = testEnvironment;
     _configuration            = configuration;
     _mapper = mapper;
 }
Exemplo n.º 12
0
        public static void SetupTenant(
            Tenant tenant,
            IConfiguration configuration,
            ITestEnvironment testEnvironment,
            IFeatureManager featureManager)
        {
            var rootFolder = System.Web.Hosting.HostingEnvironment.MapPath("/");

            AppContainer.ConfigureTenant(tenant.Id, builder =>
            {
                _ = builder.RegisterModule(new CoreAutofacModule(rootFolder));
                _ = builder.RegisterModule(new LandmarkRunServicesModule(configuration, featureManager));
                _ = builder.RegisterModule(
                    new DefaultAuditEventModule(System.Web.Hosting.HostingEnvironment.MapPath("/Logs")));
                _ = builder.RegisterModule(new TenantAutofacModule(tenant, configuration, testEnvironment,
                                                                   featureManager));
            });
        }
Exemplo n.º 13
0
 Task IBlock.ExecuteAtTheEnd(ITestEnvironment testEnv)
 {
     return(Task.CompletedTask);
 }
Exemplo n.º 14
0
 Task <BlockExecutionResult> IBlock.Execute(ITestEnvironment testEnv)
 {
     return(Task.FromResult(BlockExecutionResult.NewContinue(DateTime.Today)));
 }
Exemplo n.º 15
0
 public Task ExecuteAtTheEnd(ITestEnvironment testEnv)
 {
     return(Task.CompletedTask);
 }
Exemplo n.º 16
0
 public Task <BlockExecutionResult> Execute(ITestEnvironment testEnv)
 {
     return(Task.FromResult(BlockExecutionResult.EmptyContinue));
 }
 Task <BlockExecutionResult> IBlock.Execute(ITestEnvironment testEnv)
 {
     return(Task.FromResult(BlockExecutionResult.EmptyBreak));
 }
Exemplo n.º 18
0
 public ResolveEnvironmentTest(IServiceProvider serviceProvider, TestOptions options,
                               ITestEnvironment environment) : base(serviceProvider, options)
 {
     environment.Should().NotBeNull();
 }
Exemplo n.º 19
0
 Task IBlock.ExecuteAtTheEnd(ITestEnvironment testEnv)
 {
     ((IServiceCollection)this).Clear();
     return(Task.CompletedTask);
 }
Exemplo n.º 20
0
 public void SetTestEnvironment(ITestEnvironment environment)
 {
     _testEnvironment = environment;
 }
 Task <BlockExecutionResult> IBlock.Execute(ITestEnvironment testEnv)
 {
     Logic();
     return(Task.FromResult(BlockExecutionResult.EmptyContinue));
 }
 /// <summary>
 /// Creates a test environment manager.
 /// </summary>
 /// <param name="environments">The environments, not null.</param>
 public DefaultTestEnvironmentManager(ITestEnvironment[] environments)
 {
     this.environments = environments;
 }
Exemplo n.º 23
0
 public EnvironmentTestContext(ITestEnvironment environment)
 {
     myEnvironment = environment;
 }
Exemplo n.º 24
0
 public TestRun(ITestEnvironment environment, List <MethodInfo> tests)
 {
     Environment = environment;
     Tests       = tests;
 }
Exemplo n.º 25
0
 public static ITestSession CreateSession(ITestEnvironment environment)
 {
     return new TestSession(new AnonymousConfiguration(() => environment));
 }
Exemplo n.º 26
0
 public ElementEnvironment(XElement nsElement, ITestEnvironment env)
 {
     NamespaceElement = nsElement;
     Environment      = env;
 }
 public DocumentFactoryProvider(ITestEnvironment environment)
 {
     _environment = environment;
 }