MisterJames / GenFu

GenFu is a library you can use to generate realistic test data. It is composed of several property fillers that can populate commonly named properties through reflection using an internal database of values or randomly created data. You can override any of the fillers, give GenFu hints on how to fill them.
Other
831 stars 100 forks source link

Trouble with enums starting at 1 #136

Closed unklyf closed 6 years ago

unklyf commented 6 years ago

Code to reproduce :

A.Configure<Person>().Fill(x => x.Gender).WithRandom(new Gender[] { Gender.Male, Gender.Female })) Gender is an enum where Male = 1 and Female = 2

The person gender property is always fill to zero.

stimms commented 6 years ago

Hi @unklyf which version was exhibiting this issue? I tried with the latest and these tests passed

        [Fact]
        public void An_enum_should_be_filled_with_configuration()
        {
            A.Configure<BlogPost>().Fill(x => x.Type)
                .WithRandom(new BlogTypeEnum[] { BlogTypeEnum.Update, BlogTypeEnum.ProductRelease });
            var post = A.New<BlogPost>();
            Assert.True(post.Type  == BlogTypeEnum.Update || post.Type == BlogTypeEnum.ProductRelease);
        }