I have the following problem. This is a simple example of some classes I have (each have dependencies on other classes).
public Class1()
{
public Class1(Class2 class2)
{
}
}
public Class2()
{
public Class2(Class3 class3)
{
}
}
public Class3()
{
public Class1 class1;
public Class3(Class1 class1)
{
this.class1 = class1;
}
}
I then have the following code initialising the objects.
Class1 class1 = null;
Class2 class2 = null;
Class3 class3 = null;
class3 = new Class3(class1);
class2 = new Class2(class3);
class1 = new Class1(class2);
Assert.IsNotNull(class3.class1)
The problem I have is that the assert is always null, even though class1 has been initalized. One condition I do have is that I only want there to be one instance of each class created.
Can anybody advise the best way to make sure the assert passes.
class1 is not initialized to its object when class3 is created, thus class3’s instance of it is null.
The proper way to make this test pass is: