Skip to content

Properties on base classes not populated beyond 2 levels #132

@cjdutoit

Description

@cjdutoit

ISSUE: When a class derive from a class that derive from another class, then all the properties is not filled as expected.

public class BaseId
{
        public string Id { get; set; }
}

public class BaseWithAudit : BaseId
{
        public string CreatedBy { get; set; }
        public string UpdatedBy { get; set; }        
}

public class Person : BaseWithAudit
{
        public string Name { get; set; }
        public string LastName { get; set; }
}

Using the above classes to create a basic unit test, the test fails if the derived class have a base implementation of more than one level.

var filler = new Filler<Person>();
var x = filler.Create();

x.Name.Should().NotBeNullOrEmpty();
x.LastName.Should().NotBeNullOrEmpty();
x.CreatedBy.Should().NotBeNullOrEmpty();
x.UpdatedBy.Should().NotBeNullOrEmpty();
x.Id.Should().NotBeNullOrEmpty();

resulting in:
x.Name = "Bibirit"
x.LastName = "Kubuna"
x.CreatedBy= "Gucutazijaz"
x.UpdatedBy= "Fip"
x.Id= "" ==> expected a value here

The same code just with one base class:

var filler = new Filler<BaseWithAudit>();
var x = filler.Create();

x.CreatedBy.Should().NotBeNullOrEmpty();
x.UpdatedBy.Should().NotBeNullOrEmpty();
x.Id.Should().NotBeNullOrEmpty();

All values filled as expected:
x.CreatedBy= "Bonotubirikid"
x.UpdatedBy= "Higevoka"
x.Id= "Wuf" ==>value populated as expected

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions