public void SetUp() { // init container host for testing, web api will use different one AutofacAssemblyStore.LoadAssembly("Brandscreen.Framework"); AutofacAssemblyStore.LoadAssembly("Brandscreen.Core"); AutofacAssemblyStore.LoadAssembly("Brandscreen.WebApi"); Host = HostStarter.CreateHost(); AutofacAssemblyStore.ClearAssemblies(); // clear loaded assemblies so that it won't affect web api Startup // passes the test scope to web app, so it will use to activate RepositoryTestModule // the scope will be set again on the starting of each test case in IocSupportedTests // the scope is used for resolving same instance of objects as the ones in current running test case for each http request made through the test case // e.g. the database context must be the same both in the current running test case and web api current request context, // then it is able to rollback all temporary data within the test scope. Startup.SetCurrentTestScope(Host.LifetimeScope); // init web app var ipAddress = LocalIpAddress(); Url = $"http://{ipAddress?.ToString() ?? "localhost"}:{Port}/"; Console.WriteLine("starting web app at {0}.", Url); _webApp = WebApp.Start <Startup>(Url); Console.WriteLine("started web app."); }
public virtual void MockingTestFixtureTearDown() { AutofacAssemblyStore.ClearAssemblies(); }