Example #1
0
 private static void AmmendAccount(AccountAction action, Account account)
 {
     decimal currentAmount = account.Balance;
     account.Balance = action.TransactionType == TransactionType.Debit
         ? currentAmount - action.Amount
         : currentAmount + action.Amount;
 }
Example #2
0
        public void AccountActorJsonSendReceiveTests()
        {
            var account = new Account(1, "Test Account", "11223", 0);
            var accountAction = new AccountAction(TransactionType.Credit, 10);
            
            using (var actor = NetMQActor.Create(new AccountShimHandler()))
            {
                actor.SendMoreFrame("AMEND ACCOUNT");
                actor.SendMoreFrame(JsonConvert.SerializeObject(accountAction));
                actor.SendFrame(JsonConvert.SerializeObject(account));

                var updatedAccount = JsonConvert.DeserializeObject<Account>(actor.ReceiveFrameString());

                Assert.AreEqual(10.0m, updatedAccount.Balance);
            }
        }