예제 #1
0
        public void Handle_BanAccount_NonExisting()
        {
            var command = new FORFarm.Application.Accounts.Commands.BanAccount.BanAccount()
            {
                ID = 1,
            };

            var banAccountHandler = new BanAccountHandler(NewContext);

            Func <Task> act = async() => await banAccountHandler.Handle(command, CancellationToken.None);

            act.Should().Throw <NotFoundException>();
        }
예제 #2
0
        public async void Handle_BanMule_Existing()
        {
            var proxy = Data.Proxies.First();

            var account = BogusData.ValidMuleAccounts.Generate();

            account.Proxy = proxy;

            using (var context = NewContext)
            {
                context.Accounts.Add(account);
                await context.SaveChangesAsync();
            }

            var command = new FORFarm.Application.Accounts.Commands.BanAccount.BanAccount()
            {
                ID = account.ID
            };

            using (var context = NewContext)
            {
                var banAccountHandler = new BanAccountHandler(context);

                await banAccountHandler.Handle(command, CancellationToken.None);
            }

            using (var context = NewContext)
            {
                var uAccount = await context.Accounts.FindAsync(account.ID);

                var uProxy = await context.Proxies.FindAsync(proxy.ID);

                uAccount.Banned.Should().BeTrue();
                uAccount.Proxy.Should().BeNull();

                uProxy.ActiveAccounts.Should().NotContain(uAccount);
                uProxy.BannedMules.Should().Be(1);
            }
        }