public void TestHourRollOver() { VistaDateTimeIterator testIterator = new VistaDateTimeIterator( new DateTime(2008, 01, 01, 22, 0, 0) , new DateTime(2008, 01, 03) , new TimeSpan(1, 0, 0) ); List<string> values = new List<string>(); while (!testIterator.IsDone()) { testIterator.SetIterEndDate(); // put at start of loop values.Add(testIterator.GetDdrListerPart()); testIterator.AdvanceIterStartDate(); // put at end of loop } int result = string.Concat(values.ToArray()).GetHashCode(); //Spot Check - Count Assert.AreEqual(26, values.Count); String[] strings = values.ToArray(); //Spot Check - Validate Start Value Assert.IsTrue(strings[0].Equals("3080101.22")); //Spot Check - Validate End Value Assert.IsTrue(strings[25].Equals("3080102.23")); //Spot Check - Validate an Intermediate Value Assert.IsTrue(strings[14].Equals("3080102.12")); //Hash Code is not stable acrosss .Net Versions //Assert.AreEqual(1712919498, result); }
public void TestHourRollOver() { VistaDateTimeIterator testIterator = new VistaDateTimeIterator( new DateTime(2008, 01, 01, 22, 0, 0) , new DateTime(2008, 01, 03) , new TimeSpan(1, 0, 0) ); List <string> values = new List <string>(); while (!testIterator.IsDone()) { testIterator.SetIterEndDate(); // put at start of loop values.Add(testIterator.GetDdrListerPart()); testIterator.AdvanceIterStartDate(); // put at end of loop } int result = string.Concat(values.ToArray()).GetHashCode(); //Spot Check - Count Assert.AreEqual(26, values.Count); String[] strings = values.ToArray(); //Spot Check - Validate Start Value Assert.IsTrue(strings[0].Equals("3080101.22")); //Spot Check - Validate End Value Assert.IsTrue(strings[25].Equals("3080102.23")); //Spot Check - Validate an Intermediate Value Assert.IsTrue(strings[14].Equals("3080102.12")); //Hash Code is not stable acrosss .Net Versions //Assert.AreEqual(1712919498, result); }
public void TestHourRollOver() { //http://msdn.microsoft.com/en-us/library/system.string.gethashcode.aspx // If two string objects are equal, the GetHashCode method returns identical values. However, there is not a unique hash code value for each unique string value. Different strings can return the same hash code. VistaDateTimeIterator testIterator = new VistaDateTimeIterator( new DateTime(2008, 01, 01, 22, 0, 0) , new DateTime(2008, 01, 03) , new TimeSpan(1, 0, 0) ); List <string> values = new List <string>(); while (!testIterator.IsDone()) { testIterator.SetIterEndDate(); // put at start of loop values.Add(testIterator.GetDdrListerPart()); testIterator.AdvanceIterStartDate(); // put at end of loop } //Spot Check - Count Assert.AreEqual(26, values.Count); String[] strings = values.ToArray(); //Spot Check - Validate Start Value Assert.IsTrue(strings[0].Equals("3080101.22")); //Spot Check - Validate End Value Assert.IsTrue(strings[25].Equals("3080102.23")); //Spot Check - Validate an Intermediate Value Assert.IsTrue(strings[14].Equals("3080102.12")); //The MD5 hash value is stable across platforms string hash = CalculateMD5Hash(string.Concat(values.ToArray())); Assert.AreEqual("830FAB9CC0EB3A1E3855B5DF0F560213", hash); }
public void TestHourRollOver() { VistaDateTimeIterator testIterator = new VistaDateTimeIterator( new DateTime(2008, 01, 01, 22, 0, 0) , new DateTime(2008, 01, 03) , new TimeSpan(1, 0, 0) ); List<string> values = new List<string>(); while (!testIterator.IsDone()) { testIterator.SetIterEndDate(); // put at start of loop values.Add(testIterator.GetDdrListerPart()); testIterator.AdvanceIterStartDate(); // put at end of loop } int result = string.Concat(values.ToArray()).GetHashCode(); Assert.AreEqual(1712919498, result); }
public void TestHourRollOver() { VistaDateTimeIterator testIterator = new VistaDateTimeIterator( new DateTime(2008, 01, 01, 22, 0, 0) , new DateTime(2008, 01, 03) , new TimeSpan(1, 0, 0) ); List <string> values = new List <string>(); while (!testIterator.IsDone()) { testIterator.SetIterEndDate(); // put at start of loop values.Add(testIterator.GetDdrListerPart()); testIterator.AdvanceIterStartDate(); // put at end of loop } int result = string.Concat(values.ToArray()).GetHashCode(); Assert.AreEqual(1712919498, result); }
/// <summary>Iterates through dates and gets the inpatient moves for those days /// </summary> /// <param name="fromDate">Inclusive start date</param> /// <param name="toDate">Non-inclusive end date</param> /// <returns>Adt array, with length of 0 and no Adts if empty set</returns> public Adt[] getInpatientMoves(string fromDate, string toDate, string iterLength) { ArrayList allAdts = new ArrayList(); TimeSpan interval = VistaDateTimeIterator.IterationTimeSpanFromString(iterLength); // these are all the same for every query... DdrLister query = buildBasicGetInpatientMovesQuery(); query.Xref = "B"; #if REFACTORING VistaDateTimeIterator iteratingDate = new VistaDateTimeIterator(DateUtils.IsoDateStringToDateTime(fromDate) , DateUtils.IsoDateStringToDateTime(toDate) , interval ); while (!iteratingDate.IsDone()) { iteratingDate.SetIterEndDate(); query.From = iteratingDate.GetDdrListerPart(); // part restricts matches, so you actually need to do some iterating and walk through // the toDate will be used in the iteration, and the part will be the same as the iterating date // which starts as the fromDate. query.Part = iteratingDate.GetDdrListerPart(); string[] rtn = query.execute(); if (rtn != null && rtn.Length != 0) { allAdts.AddRange(toAdt(rtn)); } iteratingDate.AdvanceIterStartDate(); } #else // get initial date strings and convert // TBD VAN consider custom formatter or extract to DateUtils DateTime iteratingDate = DateUtils.IsoDateStringToDateTime(fromDate); // non-inclusive end iteration DateTime endDate = DateUtils.IsoDateStringToDateTime(toDate); while (iteratingDate.CompareTo(endDate) < 0) { string iteratingDateStr = iteratingDate.ToString("yyyyMMdd"); query.From = VistaTimestamp.fromUtcString(iteratingDateStr); // part restricts matches, so you actually need to do some iterating and walk through // the toDate will be used in the iteration, and the part will be the same as the iterating date // which starts as the fromDate. query.Part = VistaTimestamp.fromUtcString(iteratingDateStr); String[] rtn = query.execute(); if (!Object.Equals(rtn, null)) { allAdts.AddRange(MakeAdts(rtn)); } DateTime nextDate = iteratingDate.Add(interval); iteratingDate = nextDate; } #endif // REFACTORING return (Adt[])allAdts.ToArray(typeof(Adt)); }