I have the following test class:
[TestFixture]
public class Class1
{
public enum MyEnumType
{
VeryVeryVeryVeryVerySuperLongName
}
private readonly MyEnumType SNAME = MyEnumType.VeryVeryVeryVeryVerySuperLongName;
[Test]
public void MyTest()
{
var sname = default(string);
this.Given(_ => _.Something())
.When(_ => _.SomethingElse(sname))
.Then(_ => _.Result())
.WithExamples(
new ExampleTable(
"sname" ) {
{ "hello" },
})
.BDDfy();
}
private void Something() { }
private void SomethingElse(string s) { }
private void Result() { }
private void MethodUsedInOtherTest(MyEnumType myEnumType) { }
}
When I run this I get the following error:
System.ArgumentException : Requested value 'hello' was not found.
at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, ref EnumResult parseResult)
at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
at TestStack.BDDfy.ExampleValue.GetValue(Type targetType)
at TestStack.BDDfy.Processors.ScenarioExecutor.InitializeScenario()
at TestStack.BDDfy.Processors.TestRunner.Process(Story story)
at TestStack.BDDfy.Engine.Run()
at TestStack.BDDfy.BDDfyExtensions.BDDfy(Object testObject, String scenarioTitle)
at ClassLibrary1.Class1.MyTest() in Class1.cs: line 26
Changing:
private readonly MyEnumType SNAME;
to:
private readonly MyEnumType WORKING;
fixes the problem. Example project using BDDFy 4.3.1 and Nunit 2.6.4 (lastest working with my Resharper) attached to the issue. It looks like the private readonly constant hides the local variable. The error message is not very clear in this case since it's not obvious that it refers to the enum. Feel free to change the title to something more appropriate. I was not able to come up with anything better than this.
Sample project:
ClassLibrary1.zip
I have the following test class:
When I run this I get the following error:
Changing:
to:
fixes the problem. Example project using BDDFy 4.3.1 and Nunit 2.6.4 (lastest working with my Resharper) attached to the issue. It looks like the private readonly constant hides the local variable. The error message is not very clear in this case since it's not obvious that it refers to the enum. Feel free to change the title to something more appropriate. I was not able to come up with anything better than this.
Sample project:
ClassLibrary1.zip