I want to make this test pass - anyone got an idea how to do that?
public class Something
{
public string Name {get; set}
}
public interface IWithId
{
public Guid Id {get; set}
}
public class IdExtender
{
public static Object Extend(object toExtend)
{
...?
}
}
public class Tests
{
[Test]
public void Should_extend_any_object()
{
var thing = new Something { Name = "Hello World!"};
var extended = IdExtender.Extend(thing);
Assert.IsTrue(extended is IWithId);
Assert.IsTrue(extended.Id is Guid);
Assert.IsTrue(extened.Name == "Hello World!");
}
}
I guess something like this could be done with castle dynamic proxy, linfu,etc... but how?