I am having a problem with unit testing in c#. They don't give back correct one although they should.
this is the code of the method called in the test unit method
public static List<Examen> filterExamensCities(List<Examen> original, List<string> steden)
{
List<Examen> result = new List<Examen>();
foreach (Examen ex in original)
{
foreach (string stad in steden)
{
if (ex.Locatie == stad)
{
result.Add(ex);
}
}
}
return result;
}
This is the code of the test unit method
[TestMethod]
public void filterExamensCities()
{
//Creatie test data
List<Examen> origineleLijst = new List<Examen>();
origineleLijst.Add(new Examen(DateTime.Today, 2, 2, true, "Bouwmeesterstraat", 1));
origineleLijst.Add(new Examen(DateTime.Today, 2, 3, true, "Schilderstraat", 2));
origineleLijst.Add(new Examen(DateTime.Today, 2, 3, true, "Meistraat", 3));
List<string> stedenLijst = new List<string>();
stedenLijst.Add("Meistraat");
List<Examen> verwachteLijst = new List<Examen>();
verwachteLijst.Add(new Examen(DateTime.Today, 2, 3, true, "Meistraat", 3));
//methode oproepen en assert
List<Examen> resultLijst = FilterModel.filterExamensCities(origineleLijst, stedenLijst);
Assert.AreEqual(verwachteLijst, resultLijst, "Fout");
}
I am using the build in tests from visual studio.