public static void ClassInit(TestContext context)
 {
     _payPalMocked = new Mock<IPayPalService>();
     _loggerMocked = new Mock<ILog>();
     _emailerMocked = new Mock<IEmailService>();
     _db = new FakeGroveMartDb();
     _controller = new PaymentController(_loggerMocked.Object, _payPalMocked.Object, _emailerMocked.Object, _db) { ControllerContext = new FakeControllerContext() };
     _loggerMocked.Setup(p => p.ErrorFormat(It.IsAny<string>()));
 }
コード例 #2
0
        /// <summary>
        /// Unity.Mvc4 has been used for dependency injection
        /// </summary>
        /// <param name="logger">Log4net instance for logging</param>
        /// <param name="payPalService">for PayPal/Credit card payments</param>
        /// <param name="emailService">for sending emails</param>
        /// <param name="db">database where the transaction details are stoed</param>
        public PaymentController(ILog logger, IPayPalService payPalService, IEmailService emailService, IFakeGroveMartDb db)
        {
            _logger = logger;
            _payPalService = payPalService;
            _emailService = emailService;
            _groveMartdb = db as FakeGroveMartDb;

            // add some dummy order data to database
            if (_groveMartdb != null && _groveMartdb.Sets.Count == 0) _groveMartdb.AddSet(TestData.Orders);
        }