This project is read-only.

Using engine.For<>() with an Interface.

Jul 3, 2013 at 4:13 PM
engine.For<>() when using it with an interface doesn't seem to work. For instance the example from the documentation works fine with a concrete class, but when I temp the same thing using an Interface it only matches the first rule, unless i place engine.For<>() in front of every .Setup().

engine.For<IPerson>()
                .Setup(p => p.DateOfBirth)
                    .MustBeLessThan(DateTime.Now);
engine.For<IPerson>()
                .Setup(p => p.Name)
                    .MustNotBeNull()
                    .MustMatchRegex("^[a-zA-z]+$");
engine.For<IPerson>()
                .Setup(p => p.Phone)
                    .MustNotBeNull()
                    .MustMatchRegex("^[0-9]+$");
Can it it be used in this way? Any thoughts would be appreciated.
Jul 4, 2013 at 6:53 AM
Hi there,

Yes this should work fine... could you post the complete example (the one that doesn't work), and the one that works so I can have a better look please

Regards