5
使用Moq验证特定参数
public void SubmitMessagesToQueue_OneMessage_SubmitSuccessfully() { var messageServiceClientMock = new Mock<IMessageServiceClient>(); var queueableMessage = CreateSingleQueueableMessage(); var message = queueableMessage[0]; var xml = QueueableMessageAsXml(queueableMessage); messageServiceClientMock.Setup(proxy => proxy.SubmitMessage(xml)).Verifiable(); //messageServiceClientMock.Setup(proxy => proxy.SubmitMessage(It.IsAny<XmlElement>())).Verifiable(); var serviceProxyFactoryStub = new Mock<IMessageServiceClientFactory>(); serviceProxyFactoryStub.Setup(proxyFactory => proxyFactory.CreateProxy()).Returns(essageServiceClientMock.Object); var loggerStub = new Mock<ILogger>(); var client = new MessageClient(serviceProxyFactoryStub.Object, loggerStub.Object); client.SubmitMessagesToQueue(new List<IMessageRequestDTO> {message}); //messageServiceClientMock.Verify(proxy …
168
c#
unit-testing
nunit
moq