Closed CiprianCapus closed 4 years ago
I think this issue was closed because the value of enum is generating randomly but if my enum have five items in it and length is five but i never get fifth item on this situation. I test it like that ;
public enum MyEnum
{
a,
b,
c,
d,
e
}
for (int i = 0; i < 100; i++)
{
A.Configure<MyClass>()
.Fill(q => q.enummm)
.Fill(q => q.Deneme)
.Fill(q => q.Id);
var instance = A.New<MyClass>();
Console.WriteLine("my Enum value is :" + instance.enummm.ToString());
}
That's the result ;
my Enum value is :a
my Enum value is :b
my Enum value is :d
my Enum value is :b
my Enum value is :a
my Enum value is :d
my Enum value is :a
my Enum value is :a
my Enum value is :a
my Enum value is :a
my Enum value is :b
my Enum value is :d
my Enum value is :b
my Enum value is :d
my Enum value is :a
my Enum value is :d
my Enum value is :a
my Enum value is :b
my Enum value is :b
my Enum value is :a
my Enum value is :b
my Enum value is :b
my Enum value is :a
my Enum value is :a
my Enum value is :b
my Enum value is :d
my Enum value is :a
my Enum value is :c
my Enum value is :b
my Enum value is :c
my Enum value is :d
my Enum value is :a
my Enum value is :b
my Enum value is :a
my Enum value is :b
my Enum value is :d
my Enum value is :c
my Enum value is :c
my Enum value is :b
my Enum value is :d
my Enum value is :d
my Enum value is :a
my Enum value is :a
my Enum value is :c
my Enum value is :d
my Enum value is :c
my Enum value is :c
my Enum value is :d
my Enum value is :d
my Enum value is :d
my Enum value is :b
my Enum value is :a
my Enum value is :d
my Enum value is :a
my Enum value is :b
my Enum value is :b
my Enum value is :a
my Enum value is :b
my Enum value is :d
my Enum value is :d
my Enum value is :b
my Enum value is :a
my Enum value is :b
my Enum value is :a
my Enum value is :d
my Enum value is :d
my Enum value is :b
my Enum value is :d
my Enum value is :b
my Enum value is :a
my Enum value is :d
my Enum value is :a
my Enum value is :c
my Enum value is :a
my Enum value is :d
my Enum value is :d
my Enum value is :a
my Enum value is :a
my Enum value is :d
my Enum value is :b
my Enum value is :a
my Enum value is :d
my Enum value is :b
my Enum value is :b
my Enum value is :a
my Enum value is :c
my Enum value is :d
my Enum value is :d
my Enum value is :b
my Enum value is :c
my Enum value is :b
my Enum value is :a
my Enum value is :c
my Enum value is :b
my Enum value is :a
my Enum value is :b
my Enum value is :c
my Enum value is :c
my Enum value is :b
my Enum value is :d
What do you think @dpaquette ?
PS: .net Core 2.2 running on.
Yeah I could see that being an issue. I will take a look
I looked EnumFiller i saw this ;
public override object GetValue(object instance)
{
var values = Enum.GetValues(_type);
return values.GetValue(new Random().Next(values.Length-1));
}
I think main problem is subtraction.
Thanks for investigating @mfarkan and @CiprianCapus for reporting. This has been fixed and will be included in an upcoming release.
Hi
It seems that enum fields are always filled with the same value I think the issue is that a new Random instance is created in EnumFiller.cs And for example in EnumerableExtensions.cs, a static Random field is used