private void RegisterVerde() { var settings = new Verde.Settings { TestsAssembly = System.Reflection.Assembly.GetExecutingAssembly(), AuthorizationCheck = (context) => { // Here we could do something that verifies that the current user is allowed to // invoke integration tests. Maybe something like: // return context.User.IsInRole("admin"); return true; }, TestFixtureFactory = new CommonServiceLocatorTestFixtureFactory(ServiceLocator.Current) }; // Because we are using Autofac for IoC, we need this step to ensure that HttpContextWrapper gets // resolved to the Verde.Executor.HttpContextProxy rather than HttpContext.Current. This step is only // necessary if the AutofacDependencyResolver is in use. settings.BeginExecuteTestsRequest += (sender, e) => { var resolver = DependencyResolver.Current as AutofacDependencyResolver; if (resolver != null) new AutofacHttpContextModule().Configure(resolver.ApplicationContainer.ComponentRegistry); }; // Conditionally invoke this line only if integration tests should be enabled in the current environment. Verde.Setup.Initialize(settings); }
/// <summary> /// Initialize the integration tester. /// </summary> /// <remarks> /// This should be invoked from the Application_Start method in Global.asax. /// </remarks> public static void Initialize(Settings settings) { if (_initialized) throw new InvalidOperationException("Initialize method should only be called once."); _settings = settings; _settings.Validate(); IntegrationTestHandler.RegisterRoutes(); _initialized = true; }
public NUnitTestRunner(Settings settings) { _settings = settings; _fixtures = new List<NUnitTestFixture>(); foreach (var type in settings.TestsAssembly.GetTypes()) { object[] attrs = type.GetCustomAttributes(typeof(IntegrationFixtureAttribute), false); if (attrs.Length == 0) continue; var fixture = new NUnitTestFixture(type, ((IntegrationFixtureAttribute)attrs[0]).Sequence); _fixtures.Add(fixture); } _fixtures.Sort((f1, f2) => f1.Sequence.CompareTo(f2.Sequence)); }
protected void Application_Start() { IContainer container= AutofacRegistration(); ServiceLocator.SetLocatorProvider(() => new AutofacServiceLocator(container)); var settings = new Verde.Settings { TestsAssembly = System.Reflection.Assembly.GetExecutingAssembly(), AuthorizationCheck = (context) => { // Here we could do something that verifies that the current user is allowed to // invoke integration tests. Maybe something like: // return context.User.IsInRole("admin"); return true; }, TestFixtureFactory = new CommonServiceLocatorTestFixtureFactory(ServiceLocator.Current) }; // Because we are using Autofac for IoC, we need this step to ensure that HttpContextWrapper gets // resolved to the Verde.Executor.HttpContextProxy rather than HttpContext.Current. This step is only // necessary if the AutofacDependencyResolver is in use. settings.BeginExecuteTestsRequest += (sender, e) => { var resolver = DependencyResolver.Current as AutofacDependencyResolver; if (resolver != null) new AutofacHttpContextModule().Configure(resolver.ApplicationContainer.ComponentRegistry); }; // Conditionally invoke this line only if integration tests should be enabled in the current environment. Verde.Setup.Initialize(settings); System.Data.Entity.Database.SetInitializer(new MvcMusicStore.Models.SampleData()); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); }