A Journal Through My Activities, Thoughts, and Notes
#csharp #moq
in C# and Moq, how to mock
Func<BrokerContractTypeEnum, IFixMessageStrategy> strategyFactory?

var mockStrategy = new Mock<IFixMessageStrategy>();

// Set up the mock to return the mockStrategy instance
Func<BrokerContractTypeEnum, IFixMessageStrategy> strategyFactory =
new Mock<Func<BrokerContractTypeEnum, IFixMessageStrategy>>()
.Setup(f => f(It.IsAny<BrokerContractTypeEnum>()))
.Returns(mockStrategy.Object)
.Object;
 
 
Back to Top