public void When_rendering_view_then_seats_conference_view_model()
        {
            var dto = new ConferenceAlias();

            this._dao.Setup(x => x.GetConferenceAlias("demo")).Returns(dto);

            var invoker = new Mock <ControllerActionInvoker> {
                CallBase = true
            };

            invoker.Protected().Setup("InvokeActionResult", ItExpr.IsAny <ControllerContext>(),
                                      ItExpr.IsAny <ActionResult>());

            this._routeData.Values.Add("action", "Display");
            var result = invoker.Object.InvokeAction(this._sut.ControllerContext, "Display");

            Assert.IsTrue(result);
            Assert.NotNull((object)this._sut.ViewBag.Conference);
            Assert.AreSame(dto, this._sut.ViewBag.Conference);
        }
예제 #2
0
        public static PlaceOrder ToPlaceOrderCommand(this OrderViewModel model, ConferenceAlias conferenceAlias, IConferenceQueryService conferenceQueryService)
        {
            var seatTypes = conferenceQueryService.GetPublishedSeatTypes(conferenceAlias.Id);
            var command   = new PlaceOrder();

            command.AggregateRootId = GuidUtil.NewSequentialId();
            command.ConferenceId    = conferenceAlias.Id;
            command.Seats           = model.Seats.Where(x => x.Quantity > 0).Select(x =>
            {
                var seat = seatTypes.Single(y => y.Id == x.SeatType);
                return(new SeatInfo
                {
                    SeatType = x.SeatType,
                    Quantity = x.Quantity,
                    SeatName = seat.Name,
                    UnitPrice = seat.Price
                });
            }).ToList();
            return(command);
        }
        public void Setup()
        {
            this._conferenceAlias = new ConferenceAlias()
            {
                Id = Guid.NewGuid(), Code = "TestConferenceCode", Name = "Test Conference name"
            };

            this._commandBus    = 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._commandBus, 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);
        }