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

            logger.Info("MutaGen Api - Init");
        }
예제 #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");
        }
예제 #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);
        }
예제 #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));
        }
예제 #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));
        }
예제 #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;
 }
예제 #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));
            });
        }
예제 #13
0
 Task IBlock.ExecuteAtTheEnd(ITestEnvironment testEnv)
 {
     return(Task.CompletedTask);
 }
예제 #14
0
 Task <BlockExecutionResult> IBlock.Execute(ITestEnvironment testEnv)
 {
     return(Task.FromResult(BlockExecutionResult.NewContinue(DateTime.Today)));
 }
예제 #15
0
 public Task ExecuteAtTheEnd(ITestEnvironment testEnv)
 {
     return(Task.CompletedTask);
 }
예제 #16
0
 public Task <BlockExecutionResult> Execute(ITestEnvironment testEnv)
 {
     return(Task.FromResult(BlockExecutionResult.EmptyContinue));
 }
 Task <BlockExecutionResult> IBlock.Execute(ITestEnvironment testEnv)
 {
     return(Task.FromResult(BlockExecutionResult.EmptyBreak));
 }
예제 #18
0
 public ResolveEnvironmentTest(IServiceProvider serviceProvider, TestOptions options,
                               ITestEnvironment environment) : base(serviceProvider, options)
 {
     environment.Should().NotBeNull();
 }
예제 #19
0
 Task IBlock.ExecuteAtTheEnd(ITestEnvironment testEnv)
 {
     ((IServiceCollection)this).Clear();
     return(Task.CompletedTask);
 }
예제 #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;
 }
예제 #23
0
 public EnvironmentTestContext(ITestEnvironment environment)
 {
     myEnvironment = environment;
 }
예제 #24
0
 public TestRun(ITestEnvironment environment, List <MethodInfo> tests)
 {
     Environment = environment;
     Tests       = tests;
 }
예제 #25
0
 public static ITestSession CreateSession(ITestEnvironment environment)
 {
     return new TestSession(new AnonymousConfiguration(() => environment));
 }
예제 #26
0
 public ElementEnvironment(XElement nsElement, ITestEnvironment env)
 {
     NamespaceElement = nsElement;
     Environment      = env;
 }
 public DocumentFactoryProvider(ITestEnvironment environment)
 {
     _environment = environment;
 }