the 3rd assert in this test fails but if I would move the Id property from IEntity to IFoo it will work
I need to get all the properties, how to do this ? (whitout passing an instance, for some reason this way works)
[TestFixture]
public class DescriptorTests
{
[Test]
public void Test()
{
var bar = new Bar {Name = "bar",Foo = new Foo {Id = 1, Name = "foo"}};
Assert.AreEqual(2, TypeDescriptor.GetProperties(bar).Count);
Assert.AreEqual(2, TypeDescriptor.GetProperties(bar.Foo).Count);
Assert.AreEqual(2, TypeDescriptor.GetProperties(bar)// this fails
.Find("Foo", false)
.GetChildProperties()
.Count); // the count is 1 instead of 2
}
public class Bar
{
public IFoo Foo { get; set; }
public string Name { get; set; }
}
public interface IEntity
{
int Id { get; set; }
}
public interface IFoo : IEntity
{
string Name { get; set; }
}
public class Foo : IFoo
{
public int Id { get; set; }
public string Name { get; set; }
}
}