예제 #1
0
        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++);
        }