I am trying to get to grips with NUnit - i have installed it and run it successfully within one project. I want to keep productioncode seperate from testcode, so i write tests in a different project. The Test Project Links to the original project. (IDE C# Express 2010)
My Testcode looks like this:
using NUnit.Framework;
namespace test.Import
{
[TestFixture]
class XMLOpenTest
{
[Test]
public void openNotAPath(){
try
{
production.Import.XMLHandler.open("Not A Path");
}
catch
{
Assert.Fail("File Open Fail");
}
}
}
}
I know i could resolve this by making the production.Import.XMLHandler Class public, but i dont want to change my productioncode to allow this kind of testing.
How do i get around this? Can i make changes to my testcode? Are there other good ways to seperate test and production code in two projects? Are there ressources for dummys on the internet?
This is usually solved using InternalsVisibleToAttribute
. See this and this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With