public void Deserialize(IXunitSerializationInfo info)
        {
            String val = info.GetValue <String>("Value");
            UserHabitRecordsControllerTestData_WeekNoOfCount other = JsonSerializer.Deserialize <UserHabitRecordsControllerTestData_WeekNoOfCount>(val);

            // CaseID = other.CaseID;
            Dow = other.Dow;
            CompleteCondition = other.CompleteCondition;
            RecordCount       = other.RecordCount;
            if (other.RecordList.Count > 0)
            {
                RecordList.AddRange(other.RecordList);
            }
            if (other.ExpectedRuleDateList.Count > 0)
            {
                ExpectedRuleDateList.AddRange(other.ExpectedRuleDateList);
            }
        }
        public async Task CalculatePoints_Weekly_NumberOfCounts(UserHabitRecordsControllerTestData_WeekNoOfCount testData)
        {
            var context = this.fixture.GetCurrentDataContext();

            UserHabitRecordsController control = new(context);

            // Add Habit, Habit Rules
            UserHabit habit = new UserHabit();

            habit.TargetUser        = DataSetupUtility.UserA;
            habit.ValidFrom         = new DateTime(2021, 1, 1);
            habit.ValidTo           = new DateTime(2022, 12, 31);
            habit.Name              = "Habit_1";
            habit.Category          = HabitCategory.Positive;
            habit.Comment           = habit.Name;
            habit.Frequency         = HabitFrequency.Weekly;
            habit.CompleteCategory  = HabitCompleteCategory.NumberOfCount;
            habit.CompleteCondition = testData.CompleteCondition;
            habit.StartDate         = (int)testData.Dow;
            context.UserHabits.Add(habit);
            context.SaveChanges();
            Int32 nNewHabitID = habit.ID;

            UserHabitRule rule1 = new UserHabitRule();

            rule1.HabitID = habit.ID;
            rule1.RuleID  = 1;
            rule1.ContinuousRecordFrom = 1;
            rule1.ContinuousRecordTo   = 2;
            rule1.Point = 1;
            context.UserHabitRules.Add(rule1);

            UserHabitRule rule2 = new UserHabitRule();

            rule2.HabitID = habit.ID;
            rule2.RuleID  = 2;
            rule2.ContinuousRecordFrom = 2;
            rule1.ContinuousRecordTo   = 3;
            rule2.Point = 2;
            context.UserHabitRules.Add(rule2);

            UserHabitRule rule3 = new UserHabitRule();

            rule3.HabitID = habit.ID;
            rule3.RuleID  = 3;
            rule3.ContinuousRecordFrom = 3;
            rule3.Point = 4;
            context.UserHabitRules.Add(rule3);
            context.SaveChanges();

            // Add user record.
            foreach (UserHabitRecord record in testData.RecordList)
            {
                record.HabitID = nNewHabitID;
                var rst = control.Post(record);
                Assert.NotNull(rst);
                if (rst != null)
                {
                    CreatedODataResult <UserHabitRecord> rstrecord = (CreatedODataResult <UserHabitRecord>)rst.Result;
                    Assert.NotNull(rstrecord);
                }
            }

            // Check on DB directly
            var dbrecords = (from dbrecord in context.UserHabitRecords
                             where dbrecord.HabitID == nNewHabitID
                             select dbrecord).ToList();

            Assert.Equal(testData.RecordCount, dbrecords.Count);

            // Ensure rule is assigned correctly
            if (testData.ExpectedRuleDateList.Count > 0)
            {
                var rulecnt = 0;
                dbrecords.ForEach(dbr =>
                {
                    if (dbr.RuleID != null)
                    {
                        rulecnt++;

                        var ridx = testData.ExpectedRuleDateList.FindIndex(rd => rd.Date == dbr.RecordDate.Date);
                        Assert.NotEqual(-1, ridx);
                    }
                });
                Assert.Equal(testData.ExpectedRuleDateList.Count, rulecnt);
            }

            DataSetupUtility.ClearUserHabitData(context, nNewHabitID);
            context.SaveChanges();

            await context.DisposeAsync();
        }