Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple RunActions in same AppDomainContext #33

Open
marlonscalabrin opened this issue Aug 3, 2017 · 0 comments
Open

Multiple RunActions in same AppDomainContext #33

marlonscalabrin opened this issue Aug 3, 2017 · 0 comments

Comments

@marlonscalabrin
Copy link

I would like to run multiple actions in a unique AppDomainContext.
For example: execute a setup once and in the tests run Actions using previous Setup, sharing test context.
I my case I am writing my tests with Gherkin and it runs multiple steps (methods) to complete a single test.
I take a look in the code and it is simple to add this feature, something like this:

public partial class Smock : IDisposable
{
    public AppDomainContext CreateAppDomainContext(Action<ISmocksContext> action, Configuration configuration)
    {
        IAssemblyRewriter rewriter = CreateAssemblyRewriter(action, configuration);

        using (AppDomainContext context = AppDomainContext(rewriter, configuration.Logger))
        {
            configuration.Logger.Info("Creating service locator for app domain {0}", context);
            context.Invoke(new Action(() => ServiceLocator.Instance = CreateServiceLocator(configuration)));

            return context;
        }
    }

    public void RunActionInAppDomainContext(Action<ISmocksContext> action, Configuration configuration, AppDomainContext context)
    {
        configuration.Logger.Info("Invoking action in app domain {0}", context);
        context.Invoke(action, _serviceLocator.Resolve<ISmocksContext>());
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant