我想要做模擬擴展方法,但它不起作用。如何才能做到這一點? 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);