mardi 27 octobre 2015

How do you test that a list gets ordered in a unit test?

I have a method that I need to test that takes an IEnumerable<T>. It is required that this method performs a set of operations against this enumerable in a specific order.

(I have simplified the function for brevity's sake.)

public void TestMe(IEnumerable<IObject> objects) {
  foreach (var obj in objects.OrderBy(x => x.Priority)) {
    DoSomethingWithObject(obj);
    DoSomethingElseWithObject(obj);
  }
}

private DoSomethingWithObject(IObject obj) { }
private DoSomethingElseWithObject(IObject obj) { }

How do I write a test that makes sure the operations are performed in the correct order when DoSomethingWithObject and DoSomethingElseWithObject are private?

Aucun commentaire:

Enregistrer un commentaire