public static RegistrationController GetRegistrationController(string conferenceCode) { Func <ConferenceRegistrationDbContext> ctxFactory = () => new ConferenceRegistrationDbContext(ConferenceRegistrationDbContext.SchemaName); var orderDao = new OrderDao(ctxFactory, GetBlobStorage(), new JsonTextSerializer()); var conferenceDao = new ConferenceDao(ctxFactory); // Setup context mocks var requestMock = new Mock <HttpRequestBase>(MockBehavior.Strict); requestMock.SetupGet(x => x.ApplicationPath).Returns("/"); requestMock.SetupGet(x => x.Url).Returns(new Uri("http://localhost/request", UriKind.Absolute)); requestMock.SetupGet(x => x.ServerVariables).Returns(new NameValueCollection()); var responseMock = new Mock <HttpResponseBase>(MockBehavior.Strict); responseMock.Setup(x => x.ApplyAppPathModifier(It.IsAny <string>())).Returns <string>(s => s); var context = Mock.Of <HttpContextBase>(c => c.Request == requestMock.Object && c.Response == responseMock.Object); var routes = new RouteCollection(); var routeData = new RouteData(); routeData.Values.Add("conferenceCode", conferenceCode); // Create the controller and set context var controller = new RegistrationController(ConferenceHelper.BuildCommandBus(), orderDao, conferenceDao); controller.ControllerContext = new ControllerContext(context, routeData, controller); controller.Url = new UrlHelper(new RequestContext(context, routeData), routes); return(controller); }
public static OrderController GetOrderController(string conferenceCode) { Func <ConferenceRegistrationDbContext> ctxFactory = () => new ConferenceRegistrationDbContext(ConferenceRegistrationDbContext.SchemaName); var orderDao = new OrderDao(ctxFactory, GetBlobStorage(), new JsonTextSerializer()); var conferenceDao = new ConferenceDao(ctxFactory); var orderController = new OrderController(conferenceDao, orderDao, ConferenceHelper.BuildCommandBus()); var routeData = new RouteData(); routeData.Values.Add("conferenceCode", conferenceCode); orderController.ControllerContext = Mock.Of <ControllerContext>(x => x.RouteData == routeData); return(orderController); }
public static PaymentController GetPaymentController() { var paymentDao = new PaymentDao(() => new PaymentsReadDbContext(PaymentsReadDbContext.SchemaName)); return(new PaymentController(ConferenceHelper.BuildCommandBus(), paymentDao)); }