public void OldestWithMin_nAge_Variant() { var fileSystem = SetupFileSystem(); SemVerUtil semVerUtil = new SemVerUtil(fileSystem); semVerUtil.Initialize(@"C:\", "Ver"); int max = semVerUtil.VersionCount; TimeUnit time = new TimeUnit(); time = time.AddDays(4); // Test // - Should return 5 List <FileSemVer> oldest = semVerUtil.OldestWithMinAge(2, new TimeUnit("4d")); Assert.AreEqual(max - 5, oldest.Count, "A5: Incorrect number of items"); }
public void ValidateAdditionFunctions_WithNegativeValues(string timeUnitvalueToAdd, string unit, long valueToAdd, string result) { TimeUnit a = new TimeUnit(timeUnitvalueToAdd); TimeUnit b; switch (unit) { case "m": b = a.AddMinutes(valueToAdd); break; case "d": b = a.AddDays(valueToAdd); break; case "w": b = a.AddWeeks(valueToAdd); break; case "h": b = a.AddHours(valueToAdd); break; case "s": b = a.AddSeconds(valueToAdd); break; case "S": b = a.AddMilliseconds(valueToAdd); break; default: b = a.AddSeconds(valueToAdd); break; } Assert.AreEqual(result, b.Value); }
public void OldestWithMin_NAge_Versions([Range(0, 21, 1)] int n) { // We are not zero based when calling. n++; var fileSystem = SetupFileSystem(); SemVerUtil semVerUtil = new SemVerUtil(fileSystem); semVerUtil.Initialize(@"C:\", "Ver"); int max = semVerUtil.VersionCount; TimeUnit time = new TimeUnit(); time = time.AddDays(n); List <FileSemVer> oldest = semVerUtil.OldestWithMinAge(n, time); Assert.AreEqual(max - n, oldest.Count, "A5: Incorrect number of items"); for (int i = 0; i < (max - n); i++) { switch (i) { case 0: Assert.AreEqual(FIRST_VERSION, oldest[i].Version, "A100: Oldest item is incorrect"); break; case 1: Assert.AreEqual(VERSION_2, oldest[i].Version, "A110: 2nd Oldest item is incorrect"); break; case 2: Assert.AreEqual(VERSION_3, oldest[i].Version, "A120: 3rd oldest item is incorrect"); break; case 3: Assert.AreEqual(VERSION_4, oldest[i].Version, "A130: 4th oldest item is incorrect"); break; case 4: Assert.AreEqual(VERSION_5, oldest[i].Version, "A140: 5th oldest item is incorrect"); break; case 5: Assert.AreEqual(VERSION_6, oldest[i].Version, "A150: 6th oldest item is incorrect"); break; case 6: Assert.AreEqual(VERSION_7, oldest[i].Version, "A160: 7th oldest item is incorrect"); break; case 7: Assert.AreEqual(VERSION_8, oldest[i].Version, "A170: 8th oldest item is incorrect"); break; case 8: Assert.AreEqual(VERSION_9, oldest[i].Version, "A180: 9th oldest item is incorrect"); break; case 9: Assert.AreEqual(VERSION_10, oldest[i].Version, "A190: 10th oldest item is incorrect"); break; case 10: Assert.AreEqual(VERSION_11, oldest[i].Version, "A200: 11th oldest item is incorrect"); break; case 11: Assert.AreEqual(VERSION_12, oldest[i].Version, "A210: 12th oldest item is incorrect"); break; case 12: Assert.AreEqual(VERSION_13, oldest[i].Version, "A220: 13th oldest item is incorrect"); break; case 13: Assert.AreEqual(VERSION_14, oldest[i].Version, "A230: 14th oldest item is incorrect"); break; case 14: Assert.AreEqual(VERSION_15, oldest[i].Version, "A240: 15th oldest item is incorrect"); break; case 15: Assert.AreEqual(VERSION_16, oldest[i].Version, "A250: 16th oldest item is incorrect"); break; case 16: Assert.AreEqual(VERSION_17, oldest[i].Version, "A260: 17th oldest item is incorrect"); break; case 17: Assert.AreEqual(VERSION_18, oldest[i].Version, "A270: 18th oldest item is incorrect"); break; case 18: Assert.AreEqual(VERSION_19, oldest[i].Version, "A280: 19th oldest item is incorrect"); break; case 19: Assert.AreEqual(VERSION_20, oldest[i].Version, "A290: 20th oldest item is incorrect"); break; case 20: Assert.AreEqual(VERSION_21, oldest[i].Version, "A300: 21st oldest item is incorrect"); break; case 21: Assert.AreEqual(MAX_VERSION, oldest[i].Version, "A310: 22dn oldest item is incorrect"); break; case 22: Assert.AreEqual(0, oldest.Count); break; } } }