// public void InstantRangeTests(int fromInt, int toInt, int expectedStart, int expectedEnd, int expectedCount) { var from = Instant.FromInt(fromInt); var to = Instant.FromInt(toInt); var range = Instant.Range(from, to); Assert.Equal(expectedCount, range.Length); Assert.Equal(expectedStart, range[0].ToInt()); Assert.Equal(expectedEnd, range[range.Length - 1].ToInt()); }
public void BuildInstantByIntAndReturnToIntTests( int value, Type type, InstantType instType, InstantTypeGroup instTypeGroup, int[] segments ) { var inst = Instant.FromInt(value); Assert.Equal(type, inst.GetType()); Assert.Equal(inst.InstantType, instType); Assert.Equal(inst.InstantTypeGroup, instTypeGroup); if (inst.GetType() == typeof(YearInstant)) { var y = inst as YearInstant; Assert.Equal(segments[0], y.Year); Assert.Equal(value, y.ToInt()); } else if (inst.GetType() == typeof(YearHalfYearInstant)) { var yh = inst as YearHalfYearInstant; Assert.Equal(segments[0], yh.Year); Assert.Equal(segments[1], yh.HalfYear); Assert.Equal(value, yh.ToInt()); } else if (inst.GetType() == typeof(YearQuarterInstant)) { var yq = inst as YearQuarterInstant; Assert.Equal(segments[0], yq.Year); Assert.Equal(segments[1], yq.Quarter); Assert.Equal(value, yq.ToInt()); } else if (inst.GetType() == typeof(YearMonthInstant)) { var ym = inst as YearMonthInstant; Assert.Equal(segments[0], ym.Year); Assert.Equal(segments[1], ym.Month); Assert.Equal(value, ym.ToInt()); } else if (inst.GetType() == typeof(YearMonthDayInstant)) { var ymd = inst as YearMonthDayInstant; Assert.Equal(segments[0], ymd.Year); Assert.Equal(segments[1], ymd.Month); Assert.Equal(segments[2], ymd.Day); Assert.Equal(value, ymd.ToInt()); } else { Assert.False(true); } }