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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integer property WithInRange method not in range :relaxed:

mfarkan opened this issue · comments

I'm writing unit tests and my genfu class is like that ;

 public static ApplicationUser GetUser()
        {
            A.Configure<ApplicationUser>()
                .Fill(q => q.AccessFailedCount).WithinRange(0, 3)
                .Fill(q => q.Email, q => { return string.Format("{0}.{1}@gmail.com", q.UserName, q.PhoneNumber); })
                .Fill(q => q.PhoneNumber, "905384811896")
                .Fill(q => q.CreatedAt, DateTime.Now)
                .Fill(q => q.Gender, Core.Enumarations.Gender.Female)
                .Fill(q => q.EmailConfirmed, true)
                .Fill(q => q.PhoneNumberConfirmed, true)
                .Fill(q => q.Id, new Guid("FFC42A97-C75D-4F8B-85D7-9044BE829755"));
            return A.New<ApplicationUser>();
        }
AccessFailedCount = 32
AccessFailedCount = 72
AccessFailedCount = 64
AccessFailedCount = 5
AccessFailedCount = 6
AccessFailedCount = 95

And It's keep going like that.

My app running on .net core 3.1.

Thank you ! 👍

Working on a fix and have identified the source of the problem. See PR #153

thank you ! what is the cause of this ? I review your code but i didn't understand it.

It had to do with how WithinRange was registering the property filler for the ApplicationUser type but the AccessFailedCount property is actually defined on the base class.

I did a live stream while I tried to reproduce this bug and eventually found the source of the problem. You can watch it here if you're interested: https://www.youtube.com/watch?v=IuKhMSx1a7A