小编pen*_*uat的帖子

c#中的数学模数

在c#中是否有一个库函数用于数字的数学模数 - 由此我特别指的是以正整数为模的负整数应该产生正结果.

编辑提供一个例子:

-5模3应该返回1

c# modulo

26
推荐指数
2
解决办法
2万
查看次数

未检查MEF插件依赖性未加载为插件目录

我遇到了MEF没有为加载的组件获取依赖关系的问题.我们有一个目录结构,如下所示:

C:/ MSMQ/DistributionService/[主要应用]

C:/ MSMQ/Providers/[插件组件]

当然,我们正在使用DirectoryCatalog,该插件被选中,但其中一个依赖项不是.错误消息是:

2012-11-02 10:46:59,379 [1] FATAL - Assemblies required by Provider are not found
System.IO.FileNotFoundException: Could not load file or assembly 'BusinessObjects, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'BusinessObjects, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null'

=== Pre-bind state information ===
LOG: User = <redacted>
LOG: DisplayName = BusinessObjects, Version=1.5.0.0, Culture=neutral, Public
KeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/MSMQ/DistributionService/
LOG: Initial PrivatePath = NULL
Calling assembly : DistributedServicePropertyComponents, Version=1.0.0.0, Culture=neutral, …
Run Code Online (Sandbox Code Playgroud)

.net c# mef .net-assembly

7
推荐指数
1
解决办法
1571
查看次数

如何在NSubstitute中测试忽略params参数的调用?

我的代码看起来像:

eventPublisher.Publish(new SpecificEvent(stuff),
                        EventStreams.Stream1,
                        EventStreams.Stream2);
Run Code Online (Sandbox Code Playgroud)

调用定义为的方法:

Publish<T>(T eventToPublish, params EventStream[] streams) where T : IEvent;
Run Code Online (Sandbox Code Playgroud)

在我想要测试的东西中.这个事件发布是我想要测试的最重要的事情,但我不想测试它发布到哪个事件流.我如何在NSubstitute中替代测试这个被适当的事件调用,而不用考虑自己的params?到目前为止,我有:

eventPublisher.Received(1).Publish(Arg.Any<SpecificEvent>());
Run Code Online (Sandbox Code Playgroud)

当然,这与两个流的呼叫不匹配.有没有办法使用NSubstitute匹配params参数,忽略传入的参数数量?

c# testing mocking nsubstitute

3
推荐指数
1
解决办法
1592
查看次数

标签 统计

c# ×3

.net ×1

.net-assembly ×1

mef ×1

mocking ×1

modulo ×1

nsubstitute ×1

testing ×1