I want to set the default values to variables
and list
while testing my code using Nunit
.
My code
public class Myclass
{
static bool isShown = false;
protected static List<string> registery = new List<string>();
//My code
}
I need to change the default value. Because every test case this value will be changed.
I am using NUnit
to test my application. I tried some thing by referring this. But it is not working.
[TestFixture]
public class MyclassTest
{
Myclass obj = new Myclass();
[SetUp]
public void Init()
{
typeof(FusionLicenseProvider).GetField("isShown ", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance).SetValue(obj, false);
typeof(FusionLicenseProvider).GetField("registery", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance).SetValue(obj, null);
}
[TearDown]
public void Cleanup()
{
typeof(FusionLicenseProvider).GetField("isShown ", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance).SetValue(obj, false);
typeof(FusionLicenseProvider).GetField("registery", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance).SetValue(obj, null);
}
[Test]
public void Test01()
{
// Test case
}
}
Could you any one please help me to get rid from this?