I have 2 features that use a common \'When\' step but have different \'Then\' steps in different classes.
How do I access, for example, the ActionResult from my MVC
I have a helper class which lets me write
Current.Value = pageObject;
which is a wrapper over the ScenarioContext. It works off the type name, so it would need to be extended a bit if you need to access two variables of the same type
public static class Current where T : class
{
internal static T Value
{
get {
return ScenarioContext.Current.ContainsKey(typeof(T).FullName)
? ScenarioContext.Current[typeof(T).FullName] as T : null;
}
set { ScenarioContext.Current[typeof(T).FullName] = value; }
}
}
2019 edit: I would use @JoeT's answer nowadays, it looks like you get the same benefits without needing to define an extension