Beispiel #1
0
        public async Task TestDonateTokens()
        {
            User userSelf      = MockUser("Self");
            User userRecipient = MockUser("Recipient");

            _userRepoMock.Setup(r => r.FindBySimpleName(userRecipient.SimpleName))
            .Returns(Task.FromResult((User?)userRecipient));
            _tokenBankMock.Setup(b => b.GetAvailableMoney(userSelf)).Returns(Task.FromResult(1L));
            List <IEnumerable <Transaction <User> > > txInvocations = new();

            _tokenBankMock.Setup(b => b.PerformTransactions(Capture.In(txInvocations), It.IsAny <CancellationToken>()));

            CommandResult result = await _userCommands.Donate(new CommandContext(MockMessage(userSelf),
                                                                                 ImmutableList.Create("T1", "Recipient"), _argsParser));

            Assert.AreEqual("has donated T1 to @Recipient!", result.Response);
            List <Transaction <User> > txs = txInvocations.SelectMany(t => t).ToList();

            CollectionAssert.AreEquivalent(new List <Transaction <User> >
            {
                new(userSelf, -1, "donation_give"),
                new(userRecipient, 1, "donation_recieve"),
            }, txs);