What is the best way of initiating the class and hold that initialization in a variable for other method to use instead of initiating every time.
here is my code:
private Employee employee;
public Employee SystemUnderTest
{
get
{
if (employee == null)
{
employee = new Employee();
}
return employee;
}
}
//..method1 Test1
public void TestMethod1()
{
Assert.IsTrue(SystemUnderTest.IsActive());
}
//..method2 Test
public void TestMethod2()
{
Assert.IsTrue(SystemUnderTest.IsEmployeeExists());
}
PS: when debugging I noticed that it does initialize Employee object with every method.
using 3.5 framework.