Пример #1
0
        public void AccountActor_gets_stopped_with_badData()
        {
            var message      = new ChargeCreditCard(-5000);
            var accountActor = ActorOf(Props.Create(() => new AccountActor(12345)));

            EventFilter.Warning("AccountActor stopped!")
            .ExpectOne(() => accountActor.Tell(message));
        }
Пример #2
0
        public void AccountActor_negative_moneys_throws_exception_from_stripeGateway()
        {
            var message      = new ChargeCreditCard(-5000);
            var accountActor = ActorOf(Props.Create(() => new AccountActor(12345)));

            EventFilter.Exception <StripeException>()
            .ExpectOne(() => accountActor.Tell(message));
        }
Пример #3
0
        public void AccountActor_handles_chargeCreditCardCommand()
        {
            var message             = new ChargeCreditCard(5000);
            var orderProcessorActor = CreateTestProbe();
            var accountActor        = ActorOfAsTestActorRef <AccountActor>(Props.Create(() => new AccountActor(12345)), orderProcessorActor);

            accountActor.Tell(message);

            Assert.True(orderProcessorActor.ExpectMsg <AccountCharged>().Success);
        }
Пример #4
0
        public void AccountActor_gets_stopping_directive()
        {
            var message      = new ChargeCreditCard(-5000);
            var accountActor = ActorOf(
                Props.Create(() => new AccountActor(12345),
                             SupervisorStrategy.DefaultStrategy));

            EventFilter.Warning("AccountActor stopped!")
            .ExpectOne(() => accountActor.Tell(message));
        }
Пример #5
0
        private void ChargeCreditCardHandler(ChargeCreditCard chargeCreditCard)
        {
            StripeCharge stripeCharge = null;

            try {
                stripeCharge = _stripeGateway
                               .CreateCharge(chargeCreditCard.Amount);
                if (stripeCharge != null)
                {
                    Context.Parent.Tell(new AccountCharged(chargeCreditCard, true));
                }
            }
            catch (Exception) {
                Context.Parent.Tell(new AccountCharged(chargeCreditCard, false));
                throw;
            }
        }
Пример #6
0
 public AccountCharged(ChargeCreditCard chargeInfo, bool success)
 {
     ChargeInfo = chargeInfo;
     Success    = success;
 }