I have one class that have a property of another class type:
public class MyClass
{
public DepdendenceClass DependenceProp { get; set; }
private MyClass(){}
public MyClass(MyClassFactory factory)
{
this.DependenceProp = factory.DependenceProp;
}
}
public class DepdendenceClass
{
public int key { get; set; }
private DepdendenceClass() { }
public DepdendenceClass(DepdendenceClassFactory factory)
{
this.key = factory.key;
}
}
I hide the base constructor since I do not want that can be create empty instances
Each have a fluent ordered constructor that let me write this test:
[Test]
public void MyClassConstructorTest()
{
DepdendenceClass depdendencePropExpected = DepdendenceClassFactory.InitCreation()
.WithKey(1)
.Create();
MyClass myClassActual = MyClassFactory.InitCreation()
.WithDependency(depdendencePropExpected)
.Create();
Assert.That(myClassActual.DependenceProp, Is.EqualsTo(depdendencePropExpected));
}
Is there a way to isolate the MyClassConstructor Test from the constructor of the second class?