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

            // CompleteCondition = other.CompleteCondition;
            // ExpectedRecordCount = other.ExpectedRecordCount;
            if (other.RuleList.Count > 0)
            {
                RuleList.AddRange(other.RuleList);
            }
            if (other.RecordDatesList.Count > 0)
            {
                RecordDatesList.AddRange(other.RecordDatesList);
            }
            if (other.ExpectedRecordList.Count > 0)
            {
                ExpectedRecordList.AddRange(other.ExpectedRecordList);
            }
        }
        public async Task CalculatePoints_Daily_NumberOfTimes(UserHabitRecordsControllerTestData_DailyNoOfTimes testData)
        {
            var context = this.fixture.GetCurrentDataContext();
            UserHabitRecordsController control = new(context);

            // Add Habit, Habit Rule
            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_Daily_1";
            habit.Category         = HabitCategory.Positive;
            habit.Comment          = habit.Name;
            habit.Frequency        = HabitFrequency.Daily;
            habit.CompleteCategory = HabitCompleteCategory.NumberOfTimes;
            context.UserHabits.Add(habit);
            context.SaveChanges();
            Int32 nNewHabitID = habit.ID;

            foreach (var rule in testData.RuleList)
            {
                rule.HabitID = habit.ID;
                context.UserHabitRules.Add(rule);
            }
            context.SaveChanges();

            // Add user record.
            foreach (DateTime dt in testData.RecordDatesList)
            {
                UserHabitRecord record = new UserHabitRecord();
                record.HabitID    = habit.ID;
                record.RecordDate = dt;
                record.Comment    = "Test1";
                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 == habit.ID
                             orderby dbrecord.RecordDate ascending
                             select dbrecord).ToList();

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

            // Ensure rule is assigned correctly
            if (testData.ExpectedRecordList.Count > 0)
            {
                foreach (var dbrecord in dbrecords)
                {
                    var ridx = testData.ExpectedRecordList.FindIndex(rd => rd.RecordDate == dbrecord.RecordDate);
                    Assert.NotEqual(-1, ridx);

                    Assert.Equal(testData.ExpectedRecordList[ridx].RuleID, dbrecord.RuleID);
                    Assert.Equal(testData.ExpectedRecordList[ridx].ContinuousCount, dbrecord.ContinuousCount);
                }
            }

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

            await context.DisposeAsync();
        }