嘿家伙即时通讯新的NSubstitute框架。我试图测试我的一些课程,但是当我使用NSubstitute来检查接收的电话时,它说没有收到任何匹配的电话。 我想测试如果方法Tick()从事件类接收LogEvent()和HandleEvent(...)。 using System;
using System.Collections.Generic;
using System.Linq;
usin
我想要做模拟扩展方法,但它不起作用。如何才能做到这一点? public static class RandomExtensions
{
public static IEnumerable<int> NextInt32s(this System.Random random, int neededValuesNumber, int minInclusive, int maxExclusiv
我有以下代码: open NSubstitute
type MyClass()=
let myObject = Substitute.For<IMyInterface>()
do myObject.MyProperty.Returns(true)
do myObject.MyMethod().Returns(true)
在“归来”(两者),我得到的是没有定义的错
我最近开始学习如何编写单元测试,以及测试哪些功能部件以及如何模拟功能。我使用NSubstitute作为我的嘲笑框架。我的例子基本上调用一个回购类,然后使一个WEB API Web调用到外部服务,即:AddCreditCard,然后返回结果。我为AddCreditCard创建了2个单元测试,一个用于成功,另一个用于Fail。我仍然不是100%确定我正在做所有这些。单元测试通过,但我不知道我的断言是否
我想用NSubstitute通过模拟DbSet来单元测试Entity Framework 6.x。幸运的是,Scott Xu提供了一个很好的单元测试库,EntityFramework.Testing.Moq使用Moq。所以,我修改了自己的代码以适合NSubstitute,直到我想测试DbSet<T>.Add(),DbSet<T>.Remove()方法为止,它的外观一直很好。这里是我的代码位: pu
我正在实施一个存储库模式查询类和使用NSubstitute测试。 库接口: public interface IMyRepository
{
IQueryable<T> Query<T>(Expression<Func<T, bool>> filter) where T : class;
}
DateTimeProvider接口: public interface IMyDate
在NSubstitute中,是否可以指定在接收失败时应该抛出的消息?像下面这样: [Test]
public void Should_execute_command()
{
var command = Substitute.For<ICommand>();
var something = new SomethingThatNeedsACommand(command);