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

            DateInMonth       = other.DateInMonth;
            CompleteCondition = other.CompleteCondition;
            if (other.RuleList.Count > 0)
            {
                RuleList.AddRange(other.RuleList);
            }
            if (other.RecordList.Count > 0)
            {
                RecordList.AddRange(other.RecordList);
            }
            RecordCount = other.RecordCount;
            if (other.ExpectedRuleDateList.Count > 0)
            {
                ExpectedRuleDateList.AddRange(other.ExpectedRuleDateList);
            }
        }
        public async Task CalculatePoints(UserHabitRecordsControllerTestData_MonthNoOfCount 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.Monthly;
            habit.CompleteCategory  = HabitCompleteCategory.NumberOfCount;
            habit.CompleteCondition = testData.CompleteCondition;
            habit.StartDate         = testData.DateInMonth;
            context.UserHabits.Add(habit);
            context.SaveChanges();
            Int32 nNewHabitID = habit.ID;

            foreach (var rule in testData.RuleList)
            {
                rule.HabitID = nNewHabitID;
                context.UserHabitRules.Add(rule);
            }
            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();
        }