public given_controller() { this.bus = Mock.Of<ICommandBus>(); this.conferenceDao = Mock.Of<IConferenceDao>(x => x.GetConferenceAlias(conferenceAlias.Code) == conferenceAlias); this.orderDao = Mock.Of<IOrderDao>(); this.routes = new RouteCollection(); this.routeData = new RouteData(); this.routeData.Values.Add("conferenceCode", conferenceAlias.Code); 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); this.sut = new RegistrationController(this.bus, this.orderDao, this.conferenceDao); this.sut.ConferenceAlias = conferenceAlias; this.sut.ConferenceCode = conferenceAlias.Code; this.sut.ControllerContext = new ControllerContext(context, this.routeData, this.sut); this.sut.Url = new UrlHelper(new RequestContext(context, this.routeData), this.routes); }
public void GivenTheSelectedOrderItems(Table table) { conferenceInfo = ScenarioContext.Current.Get<ConferenceInfo>(); registrationController = RegistrationHelper.GetRegistrationController(conferenceInfo.Slug); var orderViewModel = RegistrationHelper.GetModel<OrderViewModel>(registrationController.StartRegistration()); Assert.NotNull(orderViewModel); registration = new RegisterToConference { ConferenceId = conferenceInfo.Id, OrderId = registrationController.ViewBag.OrderId }; foreach (var row in table.Rows) { var orderItemViewModel = orderViewModel.Items.FirstOrDefault(s => s.SeatType.Description == row["seat type"]); Assert.NotNull(orderItemViewModel); registration.Seats.Add(new SeatQuantity(orderItemViewModel.SeatType.Id, Int32.Parse(row["quantity"]))); } // Store for sharing between steps implementations ScenarioContext.Current.Set(registration); ScenarioContext.Current.Set(registrationController.ConferenceAlias); }