public void GivingJourneyStage_CalculatesGivingJourneyStageCorrectly(GivingJourneyStage?expectedGivingJourneyStage, params int[] daysAgoList) { GivingJourneySettings givingJourneySettings = new GivingJourneySettings(); givingJourneySettings.FormerGiverNoContributionInTheLastDays = 375; givingJourneySettings.FormerGiverMedianFrequencyLessThanDays = 320; givingJourneySettings.LapsedGiverNoContributionInTheLastDays = 150; givingJourneySettings.LapsedGiverMedianFrequencyLessThanDays = 100; givingJourneySettings.NewGiverContributionCountBetweenMinimum = 1; givingJourneySettings.NewGiverContributionCountBetweenMaximum = 5; givingJourneySettings.NewGiverFirstGiftInTheLastDays = 150; givingJourneySettings.OccasionalGiverMedianFrequencyDaysMinimum = 33; givingJourneySettings.OccasionalGiverMedianFrequencyDaysMaximum = 94; givingJourneySettings.ConsistentGiverMedianLessThanDays = 32; var currentDate = RockDateTime.Now; var transactionDates = new List <DateTime>(); foreach (var daysAgo in daysAgoList) { transactionDates.Add(currentDate.AddDays(-daysAgo)); } var givingJourneyStage = GivingJourneyHelper.GetGivingJourneyStage(givingJourneySettings, currentDate, transactionDates); Assert.AreEqual(expectedGivingJourneyStage, givingJourneyStage); }
public void GivingJourneyStage_CalculatesGivingJourneyStageCorrectlyWithNullSettings(GivingJourneyStage?unExpectedGivingJourneyStage, params int[] daysAgoList) { GivingJourneySettings givingJourneySettings = new GivingJourneySettings(); givingJourneySettings.FormerGiverNoContributionInTheLastDays = null; givingJourneySettings.FormerGiverMedianFrequencyLessThanDays = null; givingJourneySettings.LapsedGiverNoContributionInTheLastDays = null; givingJourneySettings.LapsedGiverMedianFrequencyLessThanDays = null; givingJourneySettings.NewGiverContributionCountBetweenMinimum = null; givingJourneySettings.NewGiverContributionCountBetweenMaximum = null; givingJourneySettings.NewGiverFirstGiftInTheLastDays = null; givingJourneySettings.OccasionalGiverMedianFrequencyDaysMinimum = null; givingJourneySettings.OccasionalGiverMedianFrequencyDaysMaximum = null; givingJourneySettings.ConsistentGiverMedianLessThanDays = null; var currentDate = RockDateTime.Now; var transactionDates = new List <DateTime>(); foreach (var daysAgo in daysAgoList) { transactionDates.Add(currentDate.AddDays(-daysAgo)); } var givingJourneyStage = GivingJourneyHelper.GetGivingJourneyStage(givingJourneySettings, currentDate, transactionDates); // with NULL giving JourneySettings, all the results should be null and not what they would be if not null Assert.AreNotEqual(unExpectedGivingJourneyStage, givingJourneyStage); Assert.AreEqual(null, givingJourneyStage); }