How to force to fill nullable properties?
ildoc opened this issue · comments
Not a bug, but since I couldn't find any documentation, I don't know where else to ask for support...
I have a class like this:
public class Thing
{
public int? Id { get; set; }
public string Description { get; set; }
public DateTime? Timestamp { get; set; }
}
And I configured like this:
A.Configure<Thing>()
.Fill(x => x.Id)
.Fill(x => x.Timestamp);
but when I create a list with var things = A.ListOf<Thing>(50);
, all of them have Id and Timestamp as null
(I'm using it in a .NET framework 4.6.2 project)
What I'm missing? How can I force nullable properties to be filled?
I'm having the same issue as well - i think that website testbed might be doing some different config, so i pasted the code int a unit test
public class Thing
{
public int? Id { get; set; }
public string Description { get; set; }
public DateTime? Timestamp { get; set; }
}
[TestMethod]
public void TestMethod_2()
{
var things = A.ListOf<Thing>(5);
foreach (var thing in things)
{
Debug.WriteLine($"Id: {thing.Id}, Descritpion: {thing.Description}, TimeStamp: {thing.Timestamp}");
}
}
and here's the debug output
Id: , Descritpion: pack, TimeStamp:
Id: , Descritpion: williamsburg, TimeStamp:
Id: , Descritpion: pack, TimeStamp:
Id: , Descritpion: apparel, TimeStamp:
Id: , Descritpion: government, TimeStamp:
Awesome - just updated to the latest version (1.4.22) - All seems to working great!