public void AccumulativeAchievementProcess()
        {
            var attemptsQuery = new AchievementAttemptService(_rockContext).Queryable()
                                .AsNoTracking()
                                .Where(saa => saa.AchievementTypeId == _achievementTypeId && _personAliasIds.Contains(saa.AchieverEntityId))
                                .OrderBy(saa => saa.AchievementAttemptStartDateTime);

            // There should be no attempts
            Assert.That.AreEqual(0, attemptsQuery.Count());

            var achievementTypeCache = AchievementTypeCache.Get(_achievementTypeId);
            var interaction          = new InteractionService(_rockContext).Queryable().FirstOrDefault(i => i.ForeignKey == KEY);
            var component            = AchievementContainer.GetComponent(ComponentEntityTypeName);

            component.Process(_rockContext, achievementTypeCache, interaction);
            _rockContext.SaveChanges();

            var attempts = attemptsQuery.ToList();

            Assert.That.IsNotNull(attempts);
            Assert.That.AreEqual(1, attempts.Count);

            // The database stores progress with only 9 digits beyond the decimal
            var progress           = decimal.Divide(COUNT, NUMBER_TO_ACHIEVE);
            var progressDifference = Math.Abs(progress - attempts[0].Progress);

            Assert.That.AreEqual(RockDateTime.Today, attempts[0].AchievementAttemptStartDateTime);
            Assert.That.AreEqual(RockDateTime.Today, attempts[0].AchievementAttemptEndDateTime);
            Assert.That.IsTrue(progressDifference < .000000001m);
            Assert.That.IsFalse(attempts[0].IsClosed);
            Assert.That.IsFalse(attempts[0].IsSuccessful);
        }
        private void GivingToAccountAchievementMain(
            int attemptCount,
            int accumulateCount,
            int achievementId,
            List <int> allowedAccountIds)
        {
            var attemptsQuery = new AchievementAttemptService(_rockContext).Queryable()
                                .AsNoTracking()
                                .Where(saa => saa.AchievementTypeId == achievementId && saa.AchieverEntityId == _personAliasId)
                                .OrderBy(saa => saa.AchievementAttemptStartDateTime);

            // There should be no attempts
            Assert.That.AreEqual(0, attemptsQuery.Count());

            var achievementTypeCache = AchievementTypeCache.Get(achievementId);
            var component            = AchievementContainer.GetComponent(ComponentEntityTypeName);
            var transactions         = component.GetSourceEntitiesQuery(achievementTypeCache, _rockContext).Where(i => i.ForeignKey == KEY).ToList();

            foreach (var sourceEntity in transactions)
            {
                var ft = ( FinancialTransaction )sourceEntity;

                // Check all of the account ids to make sure they are allowed
                // This is making sure the hierarchy logic is working as expected
                var transactionAccountIds = ft.TransactionDetails.Select(d => d.AccountId).Distinct();
                foreach (var accountId in transactionAccountIds)
                {
                    Assert.That.IsTrue(allowedAccountIds.Contains(accountId));
                }

                // See Rock.Model.Engagement.AchievementType.AchievementTypeService
                // Process each streak in it's own data context to avoid the data context changes getting too big and slow
                using (var rockContext = new RockContext())
                {
                    component.Process(rockContext, achievementTypeCache, sourceEntity);
                    rockContext.SaveChanges();
                }
            }

            var attempts = attemptsQuery.ToList();

            Assert.That.IsNotNull(attempts);
            Assert.That.AreEqual(attemptCount, attempts.Count);

            if (attemptCount > 0)
            {
                for (int i = 0; i < attempts.Count(); i++)
                {
                    Assert.That.IsTrue(attempts[i].Progress >= 0m);

                    if (attempts[i].Progress >= 1m)
                    {
                        Assert.That.IsTrue(attempts[i].IsClosed);
                        Assert.That.IsTrue(attempts[i].IsSuccessful);
                    }
                    else
                    {
                        Assert.That.IsFalse(attempts[i].IsClosed);
                        Assert.That.IsFalse(attempts[i].IsSuccessful);
                    }
                }
            }
        }