How to mock a class without default constructor using Mock.Of<T>()?
问题 Using Moq, I need to create a fake over an existing class (not interface*) that has no default ctor . I can do this using the "traditional" syntax: var fakeResponsePacket = new Mock<DataResponse>( new object[]{0, 0, 0, new byte[0]}); //specify ctor arguments fakeResponsePacket.Setup(p => p.DataLength).Returns(5); var checkResult = sut.Check(fakeResponsePacket.Object); My question is: Is there a way to do the same using the newer Mock.Of<T>() syntax ? From what I can see, there are only two