/// <summary> /// Gets a value from the context or parent context(s) using a specified key. Asserts if the key is not /// found. /// </summary> /// <typeparam name="T">The type of the value to return.</typeparam> /// <param name="context">The context.</param> /// <param name="key">The key of the value to retrieve.</param> /// <returns>The value associated with the default key.</returns> public static T GetInherited <T>(this SpecFlowContext context, string key) { if (context.TryGetValue(key, out T value)) { return(value); } //if (context is ScenarioStepContext) //{ // if (context.GetScenarioContext()?.TryGetValue(key, out value) ?? false) return value; // if (context.GetFeatureContext()?.TryGetValue(key, out value) ?? false) return value; //} if (context is ScenarioContext) { if (context.GetFeatureContext()?.TryGetValue(key, out value) ?? false) { return(value); } } throw new Exception($"'{key}' was not found."); }