コード例 #1
0
        public void GetCurrentDailyChallenge_ReturnsDayOneWhenMissedOneFullDayWithOneDayBackfill()
        {
            var cachedChallenge    = new CachedChallenge(GetFiveDayChallengeChannel());
            var recentInteractions = new List <Interaction>
            {
                new Interaction
                {
                    InteractionDateTime = RockDateTime.Now.AddDays(-2),
                    EntityId            = 1,
                    InteractionData     = new InteractionChallengeDayData
                    {
                        IsComplete = true,
                        Items      = new Dictionary <int, InteractionChallengeItemData>
                        {
                            [11] = new InteractionChallengeItemData {
                                IsComplete = true
                            },
                            [12] = new InteractionChallengeItemData {
                                IsComplete = true
                            },
                            [13] = new InteractionChallengeItemData {
                                IsComplete = true
                            }
                        }
                    }.ToJson()
                }
            };

            var currentChallenge = GetCurrentDailyChallenge(cachedChallenge, recentInteractions, 1);

            Assert.AreEqual(_fiveDayChallengeDayOneGuid, currentChallenge.Guid);
            Assert.AreEqual(0, currentChallenge.ChallengeItemValues.Count);
        }
コード例 #2
0
        public void GetMissedDays_ReturnsZeroDaysWhenNoRecentInteractions()
        {
            var dailyChallenge     = new CachedChallenge(GetFiveDayChallengeChannel());
            var recentInteractions = new List <Interaction>
            {
            };

            var missedDays = GetMissedDays(dailyChallenge, recentInteractions, 1);

            Assert.AreEqual(0, missedDays.Item1.Count);
        }
コード例 #3
0
        public void GetCurrentDailyChallenge_ReturnsDayTwoWhenMissedZeroDaysAndCompletedTodayWithOneDayBackfill()
        {
            var cachedChallenge    = new CachedChallenge(GetFiveDayChallengeChannel());
            var recentInteractions = new List <Interaction>
            {
                new Interaction
                {
                    InteractionDateTime = RockDateTime.Now.AddDays(-1),
                    EntityId            = 1,
                    InteractionData     = new InteractionChallengeDayData
                    {
                        IsComplete = true
                    }.ToJson()
                },
                new Interaction
                {
                    InteractionDateTime = RockDateTime.Now,
                    EntityId            = 2,
                    InteractionData     = new InteractionChallengeDayData
                    {
                        IsComplete = true,
                        Items      = new Dictionary <int, InteractionChallengeItemData>
                        {
                            [21] = new InteractionChallengeItemData {
                                IsComplete = true
                            },
                            [22] = new InteractionChallengeItemData {
                                IsComplete = true
                            },
                            [23] = new InteractionChallengeItemData {
                                IsComplete = true
                            }
                        }
                    }.ToJson()
                }
            };

            var currentChallenge = GetCurrentDailyChallenge(cachedChallenge, recentInteractions, 1);

            Assert.AreEqual(_fiveDayChallengeDayTwoGuid, currentChallenge.Guid);
            Assert.AreEqual(3, currentChallenge.ChallengeItemValues.Count);
            Assert.IsTrue(currentChallenge.ChallengeItemValues[_fiveDayChallengeDayTwoItemOneGuid].IsComplete);
            Assert.IsTrue(currentChallenge.ChallengeItemValues[_fiveDayChallengeDayTwoItemTwoGuid].IsComplete);
            Assert.IsTrue(currentChallenge.ChallengeItemValues[_fiveDayChallengeDayTwoItemThreeGuid].IsComplete);
        }
コード例 #4
0
        public void GetMissedDays_ReturnsTwoDaysWhenMissedTwoDaysWithTwoDayBackfill()
        {
            var dailyChallenge     = new CachedChallenge(GetFiveDayChallengeChannel());
            var recentInteractions = new List <Interaction>
            {
                new Interaction
                {
                    InteractionDateTime = RockDateTime.Now.AddDays(-3),
                    EntityId            = 1,
                    InteractionData     = new InteractionChallengeDayData
                    {
                        IsComplete = true
                    }.ToJson()
                }
            };

            var missedDays = GetMissedDays(dailyChallenge, recentInteractions, 2);

            Assert.AreEqual(2, missedDays.Item1.Count);
        }
コード例 #5
0
        public void GetMissedDays_ReturnsZeroDaysWhenMissedOnePartialDayAndOneFullDayWithOneDayBackfill()
        {
            var dailyChallenge     = new CachedChallenge(GetFiveDayChallengeChannel());
            var recentInteractions = new List <Interaction>
            {
                new Interaction
                {
                    InteractionDateTime = RockDateTime.Now.AddDays(-2),
                    EntityId            = 1,
                    InteractionData     = new InteractionChallengeDayData
                    {
                        IsComplete = false
                    }.ToJson()
                }
            };

            var missedDays = GetMissedDays(dailyChallenge, recentInteractions, 1);

            Assert.AreEqual(0, missedDays.Item1.Count);
        }
コード例 #6
0
        public void GetCurrentDailyChallenge_ReturnsDayTwoWhenMissedZeroDaysWithOneDayBackfill()
        {
            var cachedChallenge    = new CachedChallenge(GetFiveDayChallengeChannel());
            var recentInteractions = new List <Interaction>
            {
                new Interaction
                {
                    InteractionDateTime = RockDateTime.Now.AddDays(-1),
                    EntityId            = 1,
                    InteractionData     = new InteractionChallengeDayData
                    {
                        IsComplete = true
                    }.ToJson()
                }
            };

            var currentChallenge = GetCurrentDailyChallenge(cachedChallenge, recentInteractions, 1);

            Assert.AreEqual(_fiveDayChallengeDayTwoGuid, currentChallenge.Guid);
            Assert.AreEqual(0, currentChallenge.ChallengeItemValues.Count);
        }