I have a school assignment where I need to create a data-driven style of NUnit testing. Using the below code, I am able to get the data from the database, but everytime an \'Ass
you can do this using the data driven tests in nunit, but i'm not sure you can do it for data that comes from the database. something along the lines of:
[TestFixture]
public class RowTestSample
{
[RowTest]
[Row( 1)]
[Row( 2)]
[Row( 3)]
[Row( 4)]
[Row( 5)]
[Row( 6)]
public void GetProductById(int productId)
{
Assert.That(pm.GetProductById(productId),Is.Not.Null);
}
}
where the values in Row(n)
are the product ids you want to test. This will show as 6 tests, each one with a different value.
I'm not sure if these can come from the DB, but probably this is not a good thing to be doing in the test anyway.
I'm not sure of the value in these tests either, I suppose it depends on what ProductManager is doing.