mardi 6 septembre 2016

Using DI for Unit Testing

I understand using DI for dependencies and mocking them for unit tests. However when I have multiple implementations for the current feature which I am unit testing how do I inject them into the unit test.

Ex: QuickSort or MergeSort

public class TestSort
{
  ISort sort = null;
    [TestInitialize]
    public void Setup()
    {
        sort = new MergeSort(); // or any implementation which need to be injected on setup
    }

Aucun commentaire:

Enregistrer un commentaire