Simple helper-method for extracting closure values from lambdas.
Install-Package LambdaVariableExtractor
[Test]
public void ExtractValue_ActionWithVariable_Success()
{
//Arrange
var closure = "Outside";
Action actionWithClosure = () =>
{
closure = "Inside";
};
//Act
var result = actionWithClosure.ExtractValue<string>("closure");
//Assert
Assert.That(result, Is.EqualTo(closure));
}
Library is under .NET Standard 2.0