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 IEventSourcedRepository <SeatsAvailability> GetSeatsAvailabilityRepository() { var serializer = new JsonTextSerializer(); #if LOCAL Func <EventStoreDbContext> ctxFactory = () => new EventStoreDbContext("EventStore"); return(new SqlEventSourcedRepository <SeatsAvailability>(ConferenceHelper.BuildEventBus(), serializer, ctxFactory)); #else var settings = InfrastructureSettings.Read("Settings.xml"); var eventSourcingAccount = CloudStorageAccount.Parse(settings.EventSourcing.ConnectionString); var eventStore = new EventStore(eventSourcingAccount, settings.EventSourcing.SeatsAvailabilityTableName); var publisher = new EventStoreBusPublisher(ConferenceHelper.GetTopicSender("eventsAvailability"), eventStore, new EventStoreBusPublisherInstrumentation("worker", false)); var metadata = new StandardMetadataProvider(); return(new AzureEventSourcedRepository <SeatsAvailability>(eventStore, publisher, serializer, metadata, new MemoryCache("RepositoryCache"))); #endif }
public static PaymentController GetPaymentController() { var paymentDao = new PaymentDao(() => new PaymentsReadDbContext(PaymentsReadDbContext.SchemaName)); return(new PaymentController(ConferenceHelper.BuildCommandBus(), paymentDao)); }