jeudi 5 mai 2016

NUnit TestCase Expected Messages

So i want to be able to specify different Exeption messages in the TestCase but have no idea how that is done

This is the original

[Test]
        [ExpectedException(typeof(SystemException), ExpectedMessage = "Holiday cannot start or end on a weekend or non-working day")]

public void AddHolidays_StartsInvlaid()
        {}

This is it with TestCase

[TestCase("27/04/2025", "28/05/2025", "FullDay", "FullDay", ExpectedMessage = "Holiday cannot start or end on a weekend or non-working day")]
        [ExpectedException(typeof(SystemException), ExpectedMessage)]

public void AddHolidays_Exceptions(string dateFrom, string dateTo, string fromPeriod, string toPeriod)
        {}

The method works fine but i just want to be able to specify the exception message with NUnit TestCase

Aucun commentaire:

Enregistrer un commentaire