public void Setup()
 {
     _sut = new EventSourcingTestHelper <Order>();
     _sut.Setup(new OrderCommandHandler(_sut.Repository, () => new BookingDbContext(DbName)));
     _sut.Given(new AccountRegistered
     {
         SourceId = _accountId,
         Name     = "Bob",
         Password = null,
         Email    = "*****@*****.**"
     });
     _sut.Given(new OrderCreated
     {
         SourceId      = _orderId,
         AccountId     = Guid.NewGuid(),
         PickupDate    = DateTime.Now,
         PickupAddress = new Address
         {
             FullAddress = "1234 rue Saint-Hubert",
             Apartment   = "3939",
             RingCode    = "3131",
             Latitude    = 45.515065,
             Longitude   = -73.558064,
         }
     });
 }
Example #2
0
        public void Setup()
        {
            _sut = new EventSourcingTestHelper <Promotion>();

            _sut.Setup(new PromotionCommandHandler(_sut.Repository));
            _sut.Given(new PromotionCreated
            {
                SourceId                = _promoId,
                Name                    = "promo1",
                Description             = "promodesc1",
                Code                    = _code,
                AppliesToCurrentBooking = true,
                AppliesToFutureBooking  = false,
                DiscountType            = _type,
                DiscountValue           = _value,
                DaysOfWeek              = new[] { DayOfWeek.Monday, DayOfWeek.Tuesday },
                MaxUsage                = 2,
                MaxUsagePerUser         = 1,
                StartDate               = new DateTime(2014, 11, 10),
                EndDate                 = new DateTime(2015, 11, 10),
                StartTime               = new DateTime(SqlDateTime.MinValue.Value.Year, SqlDateTime.MinValue.Value.Month, SqlDateTime.MinValue.Value.Day, 10, 0, 0),
                EndTime                 = new DateTime(SqlDateTime.MinValue.Value.Year, SqlDateTime.MinValue.Value.Month, SqlDateTime.MinValue.Value.Day, 14, 0, 0),
                PublishedStartDate      = new DateTime(2014, 11, 9),
                PublishedEndDate        = new DateTime(2015, 11, 10),
                TriggerSettings         = new PromotionTriggerSettings()
            });
            _sut.Given(new PromotionActivated {
                SourceId = _promoId
            });
        }
 public void SetUp()
 {
     _accountId = Guid.NewGuid();
     _addressId = Guid.NewGuid();
     _sut       = new EventSourcingTestHelper <Account>();
     _sut.Setup(new AccountCommandHandler(_sut.Repository, null, null));
     _sut.Given(new AccountRegistered
     {
         SourceId = _accountId,
         Name     = "Bob",
         Password = null,
         Email    = "*****@*****.**"
     });
     _sut.Given(new FavoriteAddressAdded
     {
         SourceId = _accountId,
         Address  = new Address
         {
             Id           = _addressId,
             FriendlyName = "Chez François",
             Apartment    = "3939",
             FullAddress  = "1234 rue Saint-Hubert",
             RingCode     = "3131",
             Latitude     = 45.515065,
             Longitude    = -73.558064
         }
     });
 }
Example #4
0
        public void when_rejecting_confirmed_order_then_throws()
        {
            sut.Given(new OrderConfirmed {
                SourceId = OrderId
            });

            Assert.Throws <InvalidOperationException>(() => sut.When(new RejectOrder {
                OrderId = OrderId
            }));
        }
Example #5
0
 public void SetUp()
 {
     _sut = new EventSourcingTestHelper <Company>();
     _sut.Setup(new CompanyCommandHandler(_sut.Repository, null));
     _sut.Given(new CompanyCreated {
         SourceId = _companyId
     });
     _sut.Given(new TariffCreated {
         SourceId = _companyId, TariffId = _tariffRateId, Type = TariffType.Default
     });
 }
Example #6
0
 public void given_a_rating_type_setup()
 {
     _sut = new EventSourcingTestHelper <Company>();
     _sut.Setup(new CompanyCommandHandler(_sut.Repository, null));
     _sut.Given(new CompanyCreated {
         SourceId = _companyId
     });
     _sut.Given(new RatingTypeAdded {
         SourceId = _companyId
     });
 }
Example #7
0
        public void when_redeeming_a_promo_without_having_it_applied_first()
        {
            var orderId = Guid.NewGuid();

            _sut.Given(
                new PromotionUpdated
            {
                SourceId = _promoId,
                Name     = "promo1",
                Code     = _code,
                AppliesToCurrentBooking = false,
                AppliesToFutureBooking  = true,
                DiscountType            = PromoDiscountType.Cash,
                DiscountValue           = 15,
                DaysOfWeek      = new[] { DayOfWeek.Monday, DayOfWeek.Tuesday },
                MaxUsage        = 2,
                MaxUsagePerUser = 1,
                StartDate       = new DateTime(2014, 11, 10),
                EndDate         = new DateTime(2015, 11, 10),
                StartTime       = new DateTime(SqlDateTime.MinValue.Value.Year, SqlDateTime.MinValue.Value.Month, SqlDateTime.MinValue.Value.Day, 10, 0, 0),
                EndTime         = new DateTime(SqlDateTime.MinValue.Value.Year, SqlDateTime.MinValue.Value.Month, SqlDateTime.MinValue.Value.Day, 14, 0, 0)
            }
                );

            var ex = Assert.Throws <InvalidOperationException>(() => _sut.When(new RedeemPromotion
            {
                PromoId          = _promoId,
                OrderId          = orderId,
                TaxedMeterAmount = 44.12m
            }));

            Assert.AreEqual("Promotion must be applied to an order before being redeemed", ex.Message);
        }
        public void when_adding_ibs_order_info_to_order_and_order_was_cancelled_beforehand()
        {
            _sut.Given(new OrderCancelled {
                SourceId = _orderId
            });
            _sut.When(new AddIbsOrderInfoToOrder {
                OrderId = _orderId, IBSOrderId = 99
            });

            var @event = _sut.ThenHasSingle <IbsOrderInfoAddedToOrder>();

            Assert.AreEqual(_orderId, @event.SourceId);
            Assert.AreEqual(99, @event.IBSOrderId);
            Assert.AreEqual(true, @event.CancelWasRequested);
        }
        public void when_unlinking_account_from_ibs()
        {
            _sut.Given(new AccountLinkedToIbs {
                SourceId = _accountId, IbsAccountId = 123
            });
            _sut.Given(new AccountLinkedToIbs {
                SourceId = _accountId, IbsAccountId = 123, CompanyKey = "test"
            });
            _sut.When(new UnlinkAccountFromIbs {
                AccountId = _accountId
            });

            var @event = _sut.ThenHasSingle <AccountUnlinkedFromIbs>();

            Assert.AreEqual(_accountId, @event.SourceId);
        }
 public given_seat_assignments()
 {
     sut = new EventSourcingTestHelper <SeatAssignments>();
     sut.Setup(new SeatAssignmentsHandler(Mock.Of <IEventSourcedRepository <Order> >(), sut.Repository));
     sut.Given(new SeatAssignmentsCreated {
         SourceId = assignmentsId,
         OrderId  = orderId,
         Seats    = Enumerable.Range(0, 5)
                    .Select(i =>
                            new SeatAssignmentsCreated.SeatAssignmentInfo {
             Position = i,
             SeatType = seatType
         })
     },
               new SeatAssigned(assignmentsId)
     {
         Position = 0,
         SeatType = seatType,
         Attendee = new PersonalInfo {
             Email     = "*****@*****.**",
             FirstName = "A",
             LastName  = "Z"
         }
     });
 }
Example #11
0
 public void Setup()
 {
     _sut = new EventSourcingTestHelper <Company>();
     _sut.Setup(new CompanyCommandHandler(_sut.Repository, null));
     _sut.Given(new CompanyCreated {
         SourceId = _companyId
     });
     _sut.Given(new PaymentSettingUpdated
     {
         SourceId = _companyId,
         ServerPaymentSettings = new ServerPaymentSettings
         {
             PaymentMode = PaymentMethod.Cmt
         }
     });
 }
 public void Setup()
 {
     _sut = new EventSourcingTestHelper <Order>();
     _sut.Setup(new OrderCommandHandler(_sut.Repository, () => new BookingDbContext(DbName)));
     _sut.Given(new AccountRegistered
     {
         SourceId = _accountId,
         Name     = "Bob",
         Password = null,
         Email    = "*****@*****.**"
     });
     _sut.Given(new OrderManuallyPairedForRideLinq()
     {
         AccountId = _accountId,
         SourceId  = _orderId
     });
 }
        public void Setup()
        {
            _orderId   = Guid.NewGuid();
            _paymentId = Guid.NewGuid();
            _authCode  = "123456";

            _sut = new EventSourcingTestHelper <CreditCardPayment>();
            _sut.Setup(new CreditCardPaymentCommandHandler(_sut.Repository));
            _sut.Given(new CreditCardPaymentInitiated
            {
                SourceId      = _paymentId,
                OrderId       = _orderId,
                TransactionId = "the transaction",
                Amount        = 12.34m
            });
            _sut.Given(new CreditCardPaymentCaptured_V2 {
                SourceId = _paymentId
            });
        }
Example #14
0
 public void Setup()
 {
     _sut = new EventSourcingTestHelper <Account>();
     _sut.Setup(new AccountCommandHandler(_sut.Repository, new PasswordService(), null));
     _sut.Given(new AccountRegistered
     {
         SourceId = _accountId,
         Name     = "Bob Smith",
         Password = null,
         Email    = "*****@*****.**"
     });
 }
 public void setup()
 {
     _sut      = new EventSourcingTestHelper <Company>();
     _otherSut = new EventSourcingTestHelper <Account>();
     _sut.Setup(new CompanyCommandHandler(_sut.Repository, _otherSut.Repository));
     _sut.Given(new CompanyCreated {
         SourceId = _companyId
     });
     _otherSut.Given(new AccountRegistered {
         SourceId = _accountId
     });
 }
 public void SetUp()
 {
     _sut = new EventSourcingTestHelper <Company>();
     _sut.Setup(new CompanyCommandHandler(_sut.Repository, null));
     _sut.Given(new CompanyCreated {
         SourceId = _companyId
     });
     _sut.Given(new PopularAddressAdded
     {
         SourceId = _companyId,
         Address  =
             new Address
         {
             Id           = _addressId,
             FriendlyName = "Chez François popular",
             Apartment    = "3939",
             FullAddress  = "1234 rue Saint-Hubert",
             RingCode     = "3131",
             Latitude     = 45.515065,
             Longitude    = -73.558064
         }
     });
 }
Example #17
0
        public void Setup()
        {
            _orderId   = Guid.NewGuid();
            _paymentId = Guid.NewGuid();

            _sut = new EventSourcingTestHelper <CreditCardPayment>();
            _sut.Setup(new CreditCardPaymentCommandHandler(_sut.Repository));
            _sut.Given(new CreditCardPaymentInitiated
            {
                SourceId      = _paymentId,
                OrderId       = _orderId,
                TransactionId = "the transaction",
                Amount        = _preAuthAmount
            });
        }
Example #18
0
        public given_placed_order()
        {
            pricingService = new Mock <IPricingService>();
            pricingService.Setup(x => x.CalculateTotal(ConferenceId, It.IsAny <ICollection <SeatQuantity> >())).Returns(OrderTotal);
            sut = new EventSourcingTestHelper <Order>();
            sut.Setup(new OrderCommandHandler(sut.Repository, pricingService.Object));

            sut.Given(
                new OrderPlaced {
                SourceId     = OrderId,
                ConferenceId = ConferenceId,
                Seats        = new[] { new SeatQuantity(SeatTypeId, 5) },
                ReservationAutoExpiration = DateTime.UtcNow
            });
        }
        public given_a_paid_order()
        {
            sut         = new EventSourcingTestHelper <SeatAssignments>();
            orderHelper = new EventSourcingTestHelper <Order>();
            orderHelper.Setup(new OrderCommandHandler(orderHelper.Repository, Mock.Of <IPricingService>()));
            orderHelper.Given(
                new OrderPlaced {
                SourceId     = orderId,
                ConferenceId = Guid.NewGuid(),
                Seats        = new[] {
                    new SeatQuantity(Guid.NewGuid(), 5),
                    new SeatQuantity(Guid.NewGuid(), 10)
                },
                ReservationAutoExpiration = DateTime.UtcNow.AddDays(1),
                AccessCode = HandleGenerator.Generate(6)
            },
                new OrderPaymentConfirmed {
                SourceId = orderId
            });

            sut.Setup(new SeatAssignmentsHandler(orderHelper.Repository, sut.Repository));
        }
        public void when_updating_credit_card()
        {
            const string creditCardCompany = "mastercard";
            const string nameOnCard        = "Bob 2";
            var          creditCardId      = Guid.NewGuid();
            const string last4Digits       = "4025";
            const string expirationMonth   = "5";
            const string expirationYear    = "2020";
            const string token             = "jjwcnSLWm85";

            _sut.Given(new CreditCardAddedOrUpdated {
                SourceId = _accountId, CreditCardId = creditCardId
            });

            _sut.When(new AddOrUpdateCreditCard
            {
                AccountId         = _accountId,
                CreditCardCompany = creditCardCompany,
                CreditCardId      = creditCardId,
                NameOnCard        = nameOnCard,
                Last4Digits       = last4Digits,
                ExpirationMonth   = expirationMonth,
                ExpirationYear    = expirationYear,
                Token             = token,
                Id = Guid.NewGuid()
            });

            var @event = _sut.ThenHasSingle <CreditCardAddedOrUpdated>();

            Assert.AreEqual(_accountId, @event.SourceId);
            Assert.AreEqual(creditCardCompany, @event.CreditCardCompany);
            Assert.AreEqual(nameOnCard, @event.NameOnCard);
            Assert.AreEqual(creditCardId, @event.CreditCardId);
            Assert.AreEqual(last4Digits, @event.Last4Digits);
            Assert.AreEqual(expirationMonth, @event.ExpirationMonth);
            Assert.AreEqual(expirationYear, @event.ExpirationYear);
            Assert.AreEqual(token, @event.Token);
        }
        public void when_ridelinq_order_is_still_active_after_30_days()
        {
            var date = DateTime.UtcNow;

            _sut.Given(new OrderStatusChangedForManualRideLinq
            {
                Status   = OrderStatus.WaitingForPayment,
                SourceId = _orderId,
                LastTripPollingDateInUtc = date.AddHours(-4)
            });

            _sut.When(new ChangeOrderStatusForManualRideLinq
            {
                OrderId = _orderId,
                Status  = OrderStatus.TimedOut,
                LastTripPollingDateInUtc = date
            });

            var @event = _sut.ThenHasOne <OrderStatusChangedForManualRideLinq>();

            Assert.AreEqual(_orderId, @event.SourceId);
            Assert.AreEqual(OrderStatus.TimedOut, @event.Status);
            Assert.AreEqual(date, @event.LastTripPollingDateInUtc);
        }