使用 Rhino Mocks 保存到存储库

发布于 2024-09-10 04:42:46 字数 343 浏览 1 评论 0原文

到目前为止,我一直在编码,主要是使用Rhino Mocks在业务/服务层中执行Get方法来获取预期的列表或类型,并使Rhino Mocks为我返回它,我的问题是如何测试设置/保存调用,例如void SaveCustomers(Customer)

我有一个名为 GetCustomers 的调用,我可以在 SaveCustomers 调用之后立即使用 Rhino 模拟来调用它,看看它是否有效将其保存到内存中?我已经尝试过模拟我的存储库并调用它,但它返回 null,正确的语法是什么?我找不到使用 StrictMock 或GenerateStub 的示例。

谢谢!

I have so far been coding by doing mostly Get methods in my business/service layer using Rhino Mocks to get an expected List or type and making Rhino Mocks return it for me, my question is how do I test a set/save call, e.g void SaveCustomers(Customer)

I have a call called GetCustomers, can I use Rhino mocks to call this immediately after my SaveCustomers call to see if it saved it into memory? I have tried this my mocking my repo and calling it but it returns a null, what is the correct syntax? I can't find an example using StrictMock or GenerateStub.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

虚拟世界 2024-09-17 04:42:46

如果您正在谈论使用 Rhino Mocks 来模拟存储库,则不需要让它调用 GetCustomers,您可以使用如下语法直接检查它(使用“AAA”样式):

IMyRepository repository = MockRepository.GenerateMock<IMyRepository>();
// do stuff with repository
repository.AssertWasCalled(x => x.SaveCustomers(myTestCustomer));

If you're talking about using Rhino Mocks to mock the repository, you wouldn't need to get it to call GetCustomers, you can check it directly using syntax like this (using the 'AAA' style):

IMyRepository repository = MockRepository.GenerateMock<IMyRepository>();
// do stuff with repository
repository.AssertWasCalled(x => x.SaveCustomers(myTestCustomer));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文