cost 45 ms
如何为具有内部构造函数的 model 创建测试替身? 使用 c#、xunit 和 nsubstitute - How to create a test double for model that has internal constructor? using c#, xunit and nsubstitute

我有一个调用 azure API 的方法来列出给定容器中的 blob。 然后我有一些业务逻辑(主要基于它们的名称),然后此方法删除了一些 blob。 所以调用了BlobContainerClient.GetBlobs 现在我想创建一些单元测试,以确保我的代码确实按照我的意愿执行(使用 xunit ...

NSubstitute Mocking 表达式和参数 - NSubstitute Mocking Expressions along with params

我有一个名为 TestClass 的以下 class 和一个 function。 在测试类中 这就是我尝试使用 NSubstitute 模拟上述方法的方式。 它符合要求,但调用时的模拟方法不包括集合中的两个 Animal object,因为集合长度为零。 我有一种感觉,因为我不是 mocking 参 ...

如何针对布尔值断言以确认导致在 C# 中引发异常? - How do I assert against a Boolean value to confirm that causes an exception to be thrown in C#?

我正在为我的应用程序编写单元测试,并试图确保在我的一项服务中抛出异常。 该异常是基于真/假条件引发的,但我不确定如何使其工作。 我在单元测试中使用 NSubstitute 进行模拟,在测试框架中使用 MSTest。 这是我的单元测试。 如您所见,测试方法装饰有预期的异常类型和我们希望看到的消息 ...

Mocking 带有可选参数的 function 带有固定参数,在 C# 中使用 Nsubstitute 返回 null - Mocking a function with optional parameter with fixed parameter using Nsubstitute in C# returns null

我一直在尝试模拟一个 function,它包含带有固定参数的可选参数,但每次我得到一个 null 值时,这里是我在接口中定义的 function,我想模拟它: 调用此 function 的方法: 这是我的测试方法: 每当我在 ExportSpecimens 中点击function时,我都会得到nu ...

AutoFixture 与 AutoNSubstituteCustomization:在 ReadOnly IEnumerable 上设置 object 计数<t>财产</t> - AutoFixture with AutoNSubstituteCustomization: Set object count on ReadOnly IEnumerable<t> property

我的测试要求我在主实体集合的 IEnumerable 属性中有不同数量的对象。 我一直在搜索有关此的文档,但找不到任何东西。 这是我的意思的示例(请注意,基本实体是使用AutoNSubstituteCustomization创建的) ITransaction的样子 我知道我可以设置fixture. ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM