public TotesActor(GetToteByIdQuery getTote, ILogger <TotesActor> logger, FinishToteAmountsLogicQuery rewardsLogic, FinishToteCommand finishTote, AddBetToToteCommand addBetToTote, SlackApiWrapper slack, SaveToteReportPointCommand saveToteReportPoint) { _getTote = getTote; _logger = logger; _rewardsLogic = rewardsLogic; _finishTote = finishTote; _addBetToTote = addBetToTote; _slack = slack; _saveToteReportPoint = saveToteReportPoint; ReceiveAsync <ToteCancelledMessage>(HandleToteCancel); ReceiveAsync <ToteFinishedMessage>(HandleToteFinish); ReceiveAsync <ToteStatusMessage>(CreateNewToteStatusReportInSlack); ReceiveAsync <TotePlaceBetMessage>(HandlePlaceBet); }
public void TestSimpleRewards() { var q = new FinishToteAmountsLogicQuery(); var t = new Tote { Owner = "owner", Options = new[] { new ToteOption { Id = "o1", Bets = new[] { new ToteBet { Amount = 100, User = "******" }, new ToteBet { Amount = 200, User = "******" } } }, new ToteOption { Id = "o2", Bets = new[] { new ToteBet { Amount = 300, User = "******" }, new ToteBet { Amount = 300, User = "******" } } } } }; var r = q.CalcRewards(t, "o1"); decimal total = 900; decimal percent = total / 20m; decimal onethird = ((900 - percent) / 3).Trim(); decimal twothird = (2 * ((900 - percent) / 3)).Trim(); decimal remainder = total - percent - onethird - twothird; Assert.AreEqual(r.OwnerPercent, remainder + percent); Assert.AreEqual(onethird, r.ProportionalReward[0].Amount); Assert.AreEqual(twothird, r.ProportionalReward[1].Amount); Assert.AreEqual("1", r.ProportionalReward[0].Account.UserId); Assert.AreEqual("2", r.ProportionalReward[1].Account.UserId); }