public given_a_calculated_order()
            {
                this.sut.Handle(new OrderTotalsCalculated
                {
                    SourceId = orderId,
                    Lines = new[]
                    {
                        new SeatOrderLine 
                        { 
                            LineTotal = 50, 
                            SeatType = this.seatCreatedEvents[0].SourceId, 
                            Quantity = 10, 
                            UnitPrice = 5 
                        },
                    },
                    Total = 50,
                    IsFreeOfCharge = true,
                    Version = 4,
                });

                this.dto = this.dao.FindPricedOrder(orderId);
            }
            public void then_order_placed_is_idempotent()
            {
                this.sut.Handle(orderPlaced);

                dto = this.dao.FindPricedOrder(orderId);

                Assert.NotNull(dto);
                Assert.InRange(dto.ReservationExpirationDate.Value, orderPlaced.ReservationAutoExpiration.AddSeconds(-1), orderPlaced.ReservationAutoExpiration.AddSeconds(1));
                Assert.Equal(orderPlaced.Version, dto.OrderVersion);
            }
 public when_reading_order()
 {
     this.dto = this.dao.FindPricedOrder(orderId);
 }
            public given_a_new_calculated_order()
            {
                this.sut.Handle(new OrderPlaced
                {
                    SourceId = orderId,
                    ReservationAutoExpiration = DateTime.UtcNow.AddMinutes(10),
                    Version = 2,
                });
                this.sut.Handle(new OrderTotalsCalculated
                {
                    SourceId = orderId,
                    Lines = new[]
                    {
                        new SeatOrderLine 
                        { 
                            LineTotal = 50, 
                            SeatType = this.seatCreatedEvents[0].SourceId, 
                            Quantity = 10, 
                            UnitPrice = 5 
                        },
                        new SeatOrderLine 
                        { 
                            LineTotal = 10, 
                            SeatType = this.seatCreatedEvents[1].SourceId, 
                            Quantity = 1, 
                            UnitPrice = 10 
                        },
                    },
                    Total = 60,
                    IsFreeOfCharge = true,
                    Version = 9,
                });

                this.dto = this.dao.FindPricedOrder(orderId);
            }
            public void when_confirmed_then_removes_expiration()
            {
                this.sut.Handle(new OrderConfirmed { SourceId = orderId, Version = 15 });

                this.dto = this.dao.FindPricedOrder(orderId);

                Assert.Null(dto.ReservationExpirationDate);
                Assert.Equal(15, dto.OrderVersion);
            }
            public void when_seat_assignments_created_then_updates_order_with_assignments_id()
            {
                var assignmentsId = Guid.NewGuid();
                this.sut.Handle(new SeatAssignmentsCreated
                                    {
                                        SourceId = assignmentsId,
                                        OrderId = orderId,
                                    });

                this.dto = this.dao.FindPricedOrder(orderId);

                Assert.Equal(assignmentsId, dto.AssignmentsId);
                Assert.Equal(4, dto.OrderVersion);
            }
            public void expiration_is_idempotent()
            {
                this.sut.Handle(new OrderExpired { SourceId = orderId, Version = 15 });
                this.sut.Handle(new OrderExpired { SourceId = orderId, Version = 15 });

                this.dto = this.dao.FindPricedOrder(orderId);

                Assert.Null(dto);
            }
            public void when_expired_then_deletes_priced_order()
            {
                this.sut.Handle(new OrderExpired { SourceId = orderId });

                this.dto = this.dao.FindPricedOrder(orderId);

                Assert.Null(dto);
            }
            public void when_recalculated_then_replaces_line()
            {
                this.sut.Handle(new OrderTotalsCalculated
                {
                    SourceId = orderId,
                    Lines = new[]
                    {
                        new SeatOrderLine 
                        { 
                            LineTotal = 20, 
                            SeatType = this.seatCreatedEvents[1].SourceId, 
                            Quantity = 2, 
                            UnitPrice = 10 
                        },
                    },
                    Total = 20,
                    Version = 8,
                });

                this.dto = this.dao.FindPricedOrder(orderId);

                Assert.Equal(1, dto.Lines.Count);
                Assert.Equal(20, dto.Lines[0].LineTotal);
                Assert.Equal(2, dto.Lines[0].Quantity);
                Assert.Equal(10, dto.Lines[0].UnitPrice);
                Assert.Equal(20, dto.Total);
                Assert.Contains("Precon", dto.Lines.Select(x => x.Description));
                Assert.Equal(8, dto.OrderVersion);
            }
        private InitiateThirdPartyProcessorPayment CreatePaymentCommand(PricedOrder order)
        {
            // TODO: should add the line items?

            var description = "Registration for " + this.ConferenceAlias.Name;
            var totalAmount = order.Total;

            var paymentCommand =
                new InitiateThirdPartyProcessorPayment
                {
                    PaymentId = Guid.NewGuid(),
                    ConferenceId = this.ConferenceAlias.Id,
                    PaymentSourceId = order.OrderId,
                    Description = description,
                    TotalAmount = totalAmount
                };

            return paymentCommand;
        }
        private ActionResult CompleteRegistrationWithThirdPartyProcessorPayment(AssignRegistrantDetails command, PricedOrder order, int orderVersion)
        {
            var paymentCommand = CreatePaymentCommand(order);

            this.commandBus.Send(new ICommand[] { command, paymentCommand });

            var paymentAcceptedUrl = this.Url.Action("ThankYou", new { conferenceCode = this.ConferenceAlias.Code, order.OrderId });
            var paymentRejectedUrl = this.Url.Action("SpecifyRegistrantAndPaymentDetails", new { conferenceCode = this.ConferenceAlias.Code, orderId = order.OrderId, orderVersion });

            return RedirectToAction(
                "ThirdPartyProcessorPayment",
                "Payment",
                new
                {
                    conferenceCode = this.ConferenceAlias.Code,
                    paymentId = paymentCommand.PaymentId,
                    paymentAcceptedUrl,
                    paymentRejectedUrl
                });
        }
        public void when_display_valid_order_then_renders_view_with_priced_order()
        {
            // Arrange
            var orderId = Guid.NewGuid();
            var dto = new PricedOrder
            {
                OrderId = orderId,
                Total = 200,
            };

            this.orderDao.Setup(r => r.FindPricedOrder(orderId)).Returns(dto);

            // Act
            var result = (ViewResult)this.sut.Display(orderId);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(dto, result.Model);
        }
示例#13
0
        private PaymentViewModel CompleteRegistrationWithThirdPartyProcessorPayment(PricedOrder order, int orderVersion)
        {
            var paymentCommand = CreatePaymentCommand(order);

            this._commandBus.Send(paymentCommand);

            return new PaymentViewModel
            {
                ConferenceCode = this.ConferenceAlias.Code,
                PaymentId = paymentCommand.PaymentId
            };
        }