Sure thing. In this example i'll use Moq, a really awesome mocking library.
Example:
public class MyObject
{
public MyObject(object A, object B, object C)
{
// Assign your dependencies to whatever
}
}
Mock<MyObject> mockObject = new Mock<MyObject>();
Mock<MyObject> mockObject = new Mock<MyObject>(null, null, null); // Pass Nulls to specific constructor arguments, or 0 if int, etc
In many cases though, I assign Mock objects as the arguments so I can test the dependencies:
Mock<Something> x = new Mock<Something>();
MyObject mockObject = new MyObject(x.Object);
x.Setup(d => d.DoSomething()).Returns(new SomethingElse());
etc
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…