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)); }
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)); }
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); }
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)); }
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; } }
public AccountCharged(ChargeCreditCard chargeInfo, bool success) { ChargeInfo = chargeInfo; Success = success; }