The question is whether it is bad practice to have a method in your Application project that has no other purpose than to generate data for your test project.
I have a unit test that I am using to do a cursory exam to ensure that all valid inputs will run through the primary method of my application without any errors at all. I essentially run a method to pull every valid input out of the database and then run each of those through the primary method of the application. If it fails, a bool is set to false.
The sample of the code I am using to do this is below. The question is whether there is a better way to do this that won't require me to add anything to the Application code. The below method requires me to have a method(TestMethod) in the Application project that pulls all valid parameters in order to run them through the primary method(CheckAvailability) in the test project.
public void SomeUnitTest()
{
Availability Availability = new Availability();
List<TestParam> paramList = new List<TestParam>();
bool success = true;
bool expected = true;
//This method pulls every valid param from my database.
paramList = Availability.TestMethod();
//This foreach loop runs each one of those valid params through another method. If there is an error,
//success is set to false otherwise it remains true.
foreach (TestParam s in paramList)
{
try
{
InputWrapper Wrapper = new InputWrapper();
Wrapper.ApplicationName = s.APPname;
Wrapper.Location = s.APPLocation;
Availability.CheckAvailability(Wrapper);
}
catch(Exception)
{
success = false;
}
//I then assert that success remains true. If it is false, it means that
//the method failed.
Assert.AreEqual(expected, success);
}
}