public async void Handle_DeleteProxy()
        {
            //setup
            var proxy    = Data.Proxies.First();
            var accounts = BogusData.CreateFaker(false, true, false).Generate(3);

            accounts.ForEach(a => proxy.ActiveAccounts.Add(a));

            using (var context = NewContext)
            {
                context.Proxies.Add(proxy);
                await context.SaveChangesAsync();
            }

            //act
            using (var context = NewContext)
            {
                var deleteProxyHandler = new DeleteProxyHandler(context);

                await deleteProxyHandler.Handle(new FORFarm.Application.Proxies.Commands.DeleteProxy.DeleteProxy(proxy.ID),
                                                CancellationToken.None);
            }

            //verify
            using (var context = NewContext)
            {
                context.Proxies.ToList().Should().NotContain(p => p.ID == proxy.ID);

                foreach (var account in context.Accounts.Include(a => a.Proxy).ToList())
                {
                    account.Proxy.Should().BeNull();
                }
            }
        }
Beispiel #2
0
        public async void AssignAccounts_NotEnoughValidMules()
        {
            var nonMemberMules = BogusData.CreateFaker(true, false, false).Generate(MinActiveMules);
            var bannedMules    = BogusData.CreateFaker(true, true, true).Generate(MinActiveMules);

            var bots = BogusData.CreateFaker(false, true, false).Generate(MaxActiveBots);

            using (var context = NewContext){
                context.Accounts.AddRange(nonMemberMules);
                context.Accounts.AddRange(bannedMules);
                context.Accounts.AddRange(bots);

                await context.SaveChangesAsync();
            }

            var farmSetup = await AccountAssigner.AssignAccounts(NewContext, Settings);

            farmSetup.Should().NotBeNull();
            farmSetup.IsEmpty().Should().BeTrue();
        }
        public async void Handle_UpdateGameDetails_Existing()
        {
            var account         = BogusData.MixedAccounts.Generate();
            var skills          = BogusData.GenerateRandomSkills();
            var skillDictionary = skills.ToDictionary(s => s.Type, s => s.Level);

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

            var now      = DateTime.UtcNow;
            var datetime = new Mock <IDateTime>();

            datetime.Setup(d => d.UtcNow).Returns(now);

            const int daysRemaining = 5;
            var       command       = new UpdateGameDetails
            {
                ID = account.ID,
                MembershipDaysRemaining = daysRemaining,
                Skills = skillDictionary
            };

            var updateGameDetailsHandler = new UpdateGameDetailsHandler(NewContext, datetime.Object);

            await updateGameDetailsHandler.Handle(command, CancellationToken.None);

            var newDate = now.AddDays(daysRemaining);

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

            uAccount.MemberExpirationDate.Should().Be(newDate);
            uAccount.Skills.Should().BeEquivalentTo(skills);
        }