相关疑难解决方法(0)

AutoFixture作为Automocking容器与Automocking差异?

我开始使用moq但是根据我的理解,我总是要模拟所有可以调用的方法,即使我真的不关心它们.

有时需要很长时间来模拟你忘记你想做什么的东西.所以我一直在看自动模拟,但我不确定我应该使用什么.

AutoFixture作为自动模拟容器

Automocking

我根本不知道如何使用第一个.我有点得到第二个但从未真正尝试过.

我不确定一个人是否比另一个好.我唯一知道的是我使用AutoFixtures已经是第一个的依赖.

所以也许从长远来看,与第一个一起使用是有意义的,但就像我说我找不到任何关于如何使用它的基本教程.

编辑

我试图按照"Nikos Baxevanis"的例子,但我遇到了错误.

Failure: System.ArgumentException : A matching constructor for the given arguments was not found on the mocked type.
  ----> System.MissingMethodException : Constructor on type 'DatabaseProxyded46c36c8524889972231ef23659a72' not found.


var fixture = new Fixture().Customize(new AutoMoqCustomization());
        var fooMock = fixture.Freeze<Mock<IFoo>>();
       // fooMock.Setup(x => x.GetAccounts(It.IsAny<IUnitOfWork>()));
        var sut = fixture.CreateAnonymous<AdminService>();

        sut.Apply();
        fooMock.VerifyAll();
Run Code Online (Sandbox Code Playgroud)

我认为这是因为我的petapoco unitOfWork财产

PetaPoco.Database Db { get; }
Run Code Online (Sandbox Code Playgroud)

不确定我是否要以某种方式嘲笑这个或什么.

.net c# moq autofixture automocking

12
推荐指数
1
解决办法
5616
查看次数

标签 统计

.net ×1

autofixture ×1

automocking ×1

c# ×1

moq ×1