本文整理汇总了C#中IDbContext.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# IDbContext.Stub方法的具体用法?C# IDbContext.Stub怎么用?C# IDbContext.Stub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDbContext
的用法示例。
在下文中一共展示了IDbContext.Stub方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public static void Setup(TestContext testContext)
{
dbContext = MockRepository.GenerateStrictMock<IDbContext>();
returnValue = MockRepository.GenerateStrictMock<DbSet<Product>>();
dbContext.Stub(x => x.Set<Product>()).Return(returnValue);
context = new Repository(dbContext);
}
示例2: Setup
public void Setup()
{
_builder = new TestControllerBuilder();
_controller = _builder.CreateController<SampleController>();
//Required by .NET4.5+ to invoke actions
System.Web.HttpContext.Current =
new System.Web.HttpContext(new System.Web.HttpRequest("foo", "http://tempuri.org/foo", ""),
new System.Web.HttpResponse(new StringWriter()));
ServiceLocatorInitializer.InitWithFakeDBContext();
_dbContext = SmartServiceLocator<IDbContext>.GetService();
_dbContext.Stub(x => x.IsActive).Repeat.Any().Return(true);
_dbContext.Stub(x => x.BeginTransaction()).Repeat.Any().WhenCalled(x => _beginTransactionCount++);
_dbContext.Stub(x => x.CommitTransaction()).Repeat.Any().WhenCalled(x => _commitTransactionCount++);
_dbContext.Stub(x => x.CloseSession()).Repeat.Any().WhenCalled(x=> _closeSessionCount++);
}