both unit tests and interfaces to the domain objects are very common here on SO, just that the answers that I find I can not do the two concepts fit together.
According to this topic Should Domain Entities be exposed as Interfaces or as Plain Objects?
I would not have reason to create interfaces for my items but at this point I am in difficulty in creating the test
I do a quick example:
public MyClass1
{
public int id {get;set;}
public MyClass2 Class2{get;set;}
}
how can I test MyClass1 isolating it from MyClass2 if not creating his own interface then using moq to create an implementation in the test dummy?
MyClass1 mc1 = new MyClass1();
IMyClass2 moqC2 = Moq.Get<IMyCLass2>();
mc1.Id = 1
mc1.Class2 = moqC2
Aseert.That(mc1.Id, Is.EqualTo(1));
Aseert.That(mc1.Class2 , Is.EqualTo(moqC2 ));
without interface tests on MyClass1 can fail if MyClass2 has some problem
EDIT
in real project MyClass1 and MyClass2 have over 20 property (with explicit get and set) and some method to do complex operation. Here i post a basic example only for speaking about their reference
EDIT 2 to reply to jgauffin and Eben Roux good comments
some more details about my case:
According to user spec one of my primary object is "Activity" for each activity there are many status, results, peoples and each activity as society, type and classification property.
But every one of this object can live even without activity, for example user want to create a table of status with all possible status and this must be done before a single activity can be created, idem for society and all other reference.
Some are only Lookup table and have ad id, a description a start and end date and an order property.
Other (society, people and result) are complex object with other property and references (society have a type, contracts, list of employee, list af structures and processes; person has office property, list of knowledges, history of promotion and so on; the domain is much more complex with over 140 entities, simply I can not bring it back here all, hope this example is enough)
So all this object must be created without any reference to an activity but an activity can have a reference to all
A tiny part of my model