1

Closed

map<string>().using<enum> doesn't work

description

class StringAndEnum
{
    public string Name { get; set; }
    public DayOfWeek DayOfWeek { get; set; }

    public override string ToString()
    {
        return string.Format("Name: {0}, DayOfWeek: {1}", Name, DayOfWeek);
    }
}
class Program
{
    static void Main()
    {
        var item = Fabricator.Setup<StringAndEnum>()
            .For(x => x.Name).PickFrom("Mon", "Tue")
            //.For(x => x.DayOfWeek).Use(x => DayOfWeek.Wednesday) // works
            .For(x => x.DayOfWeek).Map(x => x.Name).Using(x => x == "Mon" ? DayOfWeek.Monday : DayOfWeek.Tuesday) // does not work
            .Generate();
        Debug.Assert(item.DayOfWeek != DayOfWeek.Sunday); // fails
    }
}
Closed Mar 31, 2012 at 7:37 PM by JRoughan
Resolved

comments

JRoughan wrote Mar 31, 2012 at 7:37 PM

This is now resolved. There was a problem with mapping properties together when they were both different types and both primitives.