nsubstitute

    0热度

    1回答

    我正在用单元测试覆盖我们的一些服务类,并且设法使用NSubstitute隔离/伪造dbcontext(遵循this指南)。我有一些测试已经完成并且正在工作,事情似乎没有问题,但是现在我找不到我添加到上下文中的实体。 测试代码是非常简单的: [Fact] public void CreateStore_GivenAccount_AccountIsAssignedTheStore() {

    0热度

    1回答

    我想模拟一些.NET结构与NSubstitute。 可以说,我得到了下面的结构定义: struct MyStruct { public String CustomString { get; private set; } } 不,我想设置该属性与NSubstitute返回值: MyStruct myStruct = new MyStruct(); myStruct.Custo

    0热度

    1回答

    我刚开始使用NSubstitute。我大多用Moq工作,这是我在做什么: // In my unit test on menter code herey mock: HasLogMessage(Is.EqualTo("expected value")); private void HasLogMessage(EqualConstraint s) { log.Verify(y =>

    0热度

    1回答

    我正在将一些测试对象从RhinoMocks转换为NSubstitute,并且无法设置我的模拟存储库。 见下面的以下单元测试代码: [SetUp] public void SetUp() { _converter = Substitute.For<IStatisticsConverter>(); _repository = Substitute.For<IRepository

    0热度

    1回答

    我得到一个任务,了解如何使用隔离框架。我想知道我是否用nsubstitute创造假货的方式。下面是应用程序如何看起来像的顺序图。 然后我做了单元测试并递交了练习。有人告诉我,我没有使用隔离框架来制造假货(而不是早些时候我们自己制造假货)。下面是如何的我的测试2看上去像一个例子: [Test] public void RequestEntry_WithValidId_DoorStateIs

    3热度

    1回答

    我试图用NSubstitute来模拟替代品的返回值,但我无法获得替代品以返回正确的值,因为方法签名使用的是Func。 我见过这些问题,但无法使它与我的Func一起工作。 Mocking Action<T> with NSubstitute Mocking out expression with NSubstitute 我试图嘲弄的接口是这个(有点simplyfied): public interf

    2热度

    1回答

    如何使用NUNit和NSubstitute执行单元测试,我想测试插入伪造的“GamaItem”对象并验证它是否有效,以及SaveChanges是否已触发。 Im新的单元测试,我不知道如何伪造dbContext对象。 在此先感谢。 工作单元: public class UnitOfWork: IUnitOfWork, IDisposable { private SRColorContex

    0热度

    2回答

    我想验证一个方法的调用,该方法需要Expression<Func<T, U>>类型的参数,但我无法让NSubstitute识别它。 public interface IFoo<T> { void DoThing<TProperty>(TProperty i, Expression<Func<T, TProperty>> expression); } // this almost

    0热度

    2回答

    我们正在努力将Nunit测试集成到我们的Web应用程序中。这里我们使用Nsubstitute作为嘲讽的框架。 项目架构去如下: Public class BaseService : Glass.Mapper.Sc.SitecoreContext { public BaseService(){} } Public class DerivedService : BaseService

    0热度

    1回答

    我需要与NSubstitute模拟,并需要设置LoanCreateHandler类的局部变量command模拟数据与它的参数Z。 我有这样的代码在下面给出: public class ClassA { public string Prop1 { get; set; } public string Prop2 { get; set; } … // Here I have