public StartSystem ( |
||
fixtureAssembly | ||
remotePublisher | ||
return |
public FixtureLibrary StartSystem(FixtureAssembly fixtureAssembly, MarshalByRefObject remotePublisher)
{
_publisher = (IEventPublisher)remotePublisher;
var observer = new FixtureObserver(_publisher);
// TODO -- if fails, do a Thread.Sleep and try again
_system = fixtureAssembly.System;
_lifecycle = new SystemLifecycle(_system);
// TODO -- make this be async
observer.RecordStatus("Setting up the environment");
_lifecycle.StartApplication();
try
{
var registry = new FixtureRegistry();
_system.RegisterFixtures(registry);
var container = registry.BuildContainer();
var library = TestRunnerBuilder.BuildLibrary(_lifecycle, observer, container, fixtureAssembly.Filter.CreateTypeFilter());
var containerSource = new FixtureContainerSource(container);
_runner = new TestRunner(_lifecycle, library, containerSource);
if (_listener != null)
{
_runner.Listener = _listener;
}
return library;
}
catch (TestEngineFailureException)
{
throw;
}
catch (Exception e)
{
throw new TestEngineFailureException(e.ToString());
}
}
public void LoadProject(IProject project) { lock (_locker) { Teardown(); try { _publisher.Publish <BinaryRecycleStarted>(); _proxy = BuildProxy(project); _library = _proxy.StartSystem(new FixtureAssembly(project), (MarshalByRefObject)_publisher); _publisher.Publish(new BinaryRecycleFinished(_library)); } catch (FileNotFoundException ex) { if (ex.Message.Contains(GetType().Assembly.GetName().Name)) { string message = "Could not find the StoryTeller.dll assembly in the target AppDomain."; message += "\nYou will not be able to execute tests until the StoryTeller.dll file is copied to " + project.GetBinaryFolder(); _publisher.Publish(new BinaryRecycleFailure { ErrorMessage = message }); } else { _publisher.Publish(new BinaryRecycleFailure { ErrorMessage = ex.ToString() }); } Teardown(); } catch (Exception ex) { Teardown(); _publisher.Publish(new BinaryRecycleFailure { ErrorMessage = ex.ToString() }); } } }