public DepositControllerTest()
        {
            var aEventLog = new EventLog();
            var aMockRepo = new Mock<IAccountRepository>();
            aMockRepo.Setup(aRepo => aRepo.GetAccount()).Returns(new Account(0, aEventLog));

            /*********************************************************************************************
                build mock data for ControllerContext so that context-dependent properties can be tested
                (headers, routing, etc...)
            *********************************************************************************************/
            var config = new HttpConfiguration();
            var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/account");
            var route = config.Routes.MapHttpRoute("DefaultApi", "api/v{version}/{controller}/{id}");
            var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", "Deposit" } });

            /*********************************************************************************************
                build the Controller (class under test) and initialize it with the ControllerContext
            *********************************************************************************************/
            _controller = new DepositController(aMockRepo.Object)
            {
                ControllerContext = new HttpControllerContext(config, routeData, request),
                Request = request
            };
            _controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
        }
Пример #2
0
 public AccountTest()
 {
     _eventLog = new EventLog();
     _account = new Account(10, _eventLog);	// instantiate account for test with interest rate of 10%
 }
 public EventLogController(EventLog theEventLog)
 {
     _eventLog = theEventLog;
 }
 public AccountRepositoryTest()
 {
     _eventLog = new EventLog();
     _repository = new AccountRepository(_eventLog);
 }