使用moq将参数的值赋给变量 [英] Assign values of the arguments to variable using moq

查看:78
本文介绍了使用moq将参数的值赋给变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在moq设置中,我试图将其中一个参数的值赋给字符串变量。虽然我使用回调但仍然变量似乎有空值。



我尝试过:



我试过这个



In moq setup I am trying to assign the value of one of the argument to a string variable. Although I used callback but still the variable seems to have null value.

What I have tried:

I tried this

Mock<ILunaService> partialMockLunaService = new Mock<ILunaService>(MockBehavior.Strict);
            partialMockLunaService.Setup(x => x.TranslateText(It.IsAny<MachineTranslationProviderEnum>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<MachineTranslationOptionsDto>()))
                .Callback<MachineTranslationProviderEnum, int, int, string, MachineTranslationOptionsDto>((a, b, c, d, e) => actualTextForTranslation = d);  

推荐答案

只知道哪些参数可以使用。



c# - 将传递的参数设置为Moq中的特定值 - Stack溢出 [ ^ ]
Only you know which parameters will work.

c# - Setting a passed parameter to a specific value in Moq - Stack Overflow[^]


这篇关于使用moq将参数的值赋给变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆