public void CheckPoint7a() { var cp = new CheckPoint(new DateTime(2015, 6, 4, 2, 0, 0, DateTimeKind.Utc));//10PM Assert.AreEqual(7, cp.CP); Assert.AreEqual(0, cp.Cycle.Id); Console.WriteLine(cp.DateTime); }
public void RightBeforeEndOfCycle() { var date = new DateTime(2015, 6, 9, 19, 59, 59, DateTimeKind.Utc);//begininng of next cycle Console.WriteLine(date); var cp = new CheckPoint(date);//1AM Assert.AreEqual(34, cp.CP); Assert.AreEqual(0, cp.Cycle.Id); }
protected CpStatus(CycleIdentifier cycle, int cp) { Cp = cp; //var localTime = new CheckPoint(cycle, cp).DateTime.ToLocalTime(); //DateTime = localTime.ToShortDateString() + " " + localTime.ToShortTimeString(); DateTime = new CheckPoint(cycle, cp).DateTime; Type = GetType().ToString(); }
protected CpStatus(CycleIdentifier cycle, int cp) { Cp = cp; //var localTime = new CheckPoint(cycle, cp).DateTime.ToLocalTime(); //DateTime = localTime.ToShortDateString() + " " + localTime.ToShortTimeString(); DateTime = new CheckPoint(cycle, cp).DateTime; Type = this.GetType().ToString(); }
public void BeginningOfNextCycle() { var date = new DateTime(2015, 6, 9, 20, 1, 0, DateTimeKind.Utc);//begininng of next cycle Console.WriteLine(date); var cp = new CheckPoint(date);//1AM Assert.AreEqual(35, cp.CP); Assert.AreEqual(0, cp.Cycle.Id); }
public void setcp0() { var cp = new CheckPoint(new DateTime(2015, 6, 2, 13, 0, 0, DateTimeKind.Utc)); var score = new CycleScore(cp.Cycle, DateTimeOffset.Now.Ticks); score.SetScore(0, new UpdateScore { EnlightenedScore = 1000, ResistanceScore = 0 }, new Mock<ICycleScoreUpdater>().Object); foreach (var summary in score.Summary(false)) { Console.WriteLine(summary); } }
public void DateTimeAmICrazy() { //var cp = new CheckPoint(DateTime.Now.AddHours(1));//1AM //Console.WriteLine(cp.CP); //Console.WriteLine(cp.Cycle.Id); //Console.WriteLine(cp.DateTime); //Console.WriteLine(cp.IsFirstMessageOfDay()); //Console.WriteLine(cp.NextUnsnoozeTime()); var cp = new CheckPoint(DateTime.UtcNow.AddHours(1)); //1AM Console.WriteLine(cp.CP); Console.WriteLine(cp.Cycle.Id); Console.WriteLine(cp.DateTime); Console.WriteLine(cp.IsFirstMessageOfDay()); Console.WriteLine(cp.NextUnsnoozeTime()); }
/// <summary> /// Cycle with checpoint scores /// </summary> /// <param name="cycleIdentifier"></param> /// <param name="timestampTicks"></param> /// <param name="isSnoozed"></param> /// <param name="currentCheckPoint"></param> /// <param name="scores"></param> public CycleScore(CycleIdentifier cycleIdentifier, long timestampTicks, bool isSnoozed, CheckPoint currentCheckPoint, params KeyValuePair<int, CpScore>[] scores) { _timestampTicks = timestampTicks; Cycle = cycleIdentifier; IsSnoozed = isSnoozed; _scores = scores.ToDictionary(score => score.Key, val=>val.Value); if (Cycle.Id > currentCheckPoint.Cycle.Id) { _maxCheckPoint = 0; } else if (Cycle.Id == currentCheckPoint.Cycle.Id) { _maxCheckPoint = currentCheckPoint.CP; } else { _maxCheckPoint = 35;//past cycles } }
/// <summary> /// return reason not updatable /// </summary> /// <param name="cpScore"></param> /// <param name="checkpoint"></param> /// <param name="currentCheckPoint"></param> /// <returns></returns> public string IsUpdatable(UpdateScore cpScore, int checkpoint, CheckPoint currentCheckPoint) { if (Cycle.Id > currentCheckPoint.Cycle.Id) { return("Cannot set a cycle that is in the future"); } if (currentCheckPoint.Cycle.Id == Cycle.Id && checkpoint > currentCheckPoint.CP) { //only check this if the cycle is the same, else it's probably a previous cycle? Add some testing to explore this. return("Cannot set a checkpoint that is in the future"); } if (HasExactScore(checkpoint, cpScore)) { return("has exact score"); } if (long.Parse(cpScore.TimeStamp) != _timestampTicks) { return("timestamp invalid"); } return(null); }
public IEnumerable <CpStatus> AllCPs() { var currentCp = CheckPoint.Current(); int cpMax; if (Cycle.Id == currentCp.Cycle.Id) { cpMax = currentCp.CP; } else if (Cycle.Id < currentCp.Cycle.Id) { cpMax = 35; } else { cpMax = 0; } for (var i = 1; i <= 35; i++) { CpScore score; if (_scores.TryGetValue(i, out score)) { yield return(new RecordedScore(score, Cycle, i)); continue; } if (i <= cpMax) { yield return(new MissingScore(i, Cycle)); continue; //return MissingCps; } yield return(new FutureScore(i, Cycle)); } }
/// <summary> /// return reason not updatable /// </summary> /// <param name="cpScore"></param> /// <param name="checkpoint"></param> /// <param name="currentCheckPoint"></param> /// <returns></returns> public string IsUpdatable(UpdateScore cpScore, int checkpoint, CheckPoint currentCheckPoint) { if (Cycle.Id > currentCheckPoint.Cycle.Id) { return "Cannot set a cycle that is in the future"; } if (currentCheckPoint.Cycle.Id == Cycle.Id && checkpoint > currentCheckPoint.CP) { //only check this if the cycle is the same, else it's probably a previous cycle? Add some testing to explore this. return "Cannot set a checkpoint that is in the future"; } if (HasExactScore(checkpoint,cpScore)) { return "has exact score"; } if (long.Parse(cpScore.TimeStamp) != _timestampTicks) { return "timestamp invalid"; } return null; }
public string NextUnsnoozeTime() { var dateTimeNow = DateTime; CheckPoint newCp; while (true) { dateTimeNow = dateTimeNow.AddHours(5); newCp = new CheckPoint(dateTimeNow); if (newCp.Cycle.Id != Cycle.Id) { break; } if (newCp.IsFirstMessageOfDay()) { break; } } var easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"); var easternTime = TimeZoneInfo.ConvertTimeFromUtc(newCp.DateTime, easternZone); return $"{easternTime.ToShortDateString()} {easternTime.ToShortTimeString()}"; }
public void TimeOfCP() { var cp = new CheckPoint(new CycleIdentifier(7),24); Console.WriteLine("{0} {1} {2} {3}", cp.Cycle.Id, cp.CP, cp.DateTime, cp.DateTime.ToLocalTime()); }
public void ZeroCP() { var lastYear = int.MaxValue; for (var i = 1; i < 100000; i++) { var cpNow = new CheckPoint(new CycleIdentifier(i), 1); if (cpNow.DateTime.Year != lastYear) { lastYear = cpNow.DateTime.Year; Console.WriteLine($"{i} - {cpNow.DateTime}"); } //first CP of the year. } }
public void Now() { var cp = new CheckPoint(DateTime.UtcNow); Console.WriteLine("{0} {1} {2} {3}", cp.Cycle.Id, cp.CP, cp.DateTime, cp.DateTime.ToLocalTime()); }
public void CheckPoint8() { var cp = new CheckPoint(new DateTime(2015, 6, 4, 5, 0, 0, DateTimeKind.Utc));//1AM Assert.AreEqual(8, cp.CP); Assert.AreEqual(0, cp.Cycle.Id); }
public void CheckPoint7b() { var cp = new CheckPoint(new DateTime(2015, 6, 4, 4, 59, 59, DateTimeKind.Utc));//12:59AM Assert.AreEqual(7, cp.CP); Assert.AreEqual(0, cp.Cycle.Id); }