mardi 26 juillet 2016

C# Unit Test: Retrieve Data from Repository

So I have to create a unit test for my data retrieve, the object i want to get is quite big. I have repositories with "GetbyId" (in there we have the retrieve of the dataobject and the mapping). I figured out it would be better to create 2 unit tests:

  1. Retrieve of the dataobject
  2. Mapping to my model

We've already created some test examples and I am checking the entities with saved xmls of the test-entity, so we are quite flexible. My Problem is with the mapping, since my Model does have some Interfaces I can't serialize it and I don't want to hardcode each example solution (because they are quite a lot too)

Has anyone an idea how I can test the mapper better?

Ps: I know, I am quite the master of explaining things badly, sorry for that.

EDIT:

Here an Example: Since IKontakt is in Person i can't serialize it so i don't know how to check it easily (this model is an example the real is about 200 rows big without counting the child rows from the interfaces)

public Person: IPerson 
{
    public Name {get; set;}
    public IContact {get; set;}
}

public Contact: IContact
{
    public Phone {get; set;} 
}

Aucun commentaire:

Enregistrer un commentaire