public void Parse_ValidRange() { var r = Range.Parse("4-6"); Assert.That(r.From, Is.EqualTo(4)); Assert.That(r.To, Is.EqualTo(6)); }
public void ParseRanges() { var ranges = Range.ParseRanges("1-2,5,10-11").ToList(); CollectionAssert.Contains(ranges, Range.Parse("1-2")); CollectionAssert.Contains(ranges, Range.Parse("5")); CollectionAssert.Contains(ranges, Range.Parse("10-11")); }
public void Parse_Invalid() { Assert.Throws <ArgumentNullException>(() => Range.Parse(null)); var input = string.Empty; Assert.Throws <ArgumentException>(() => Range.Parse(input)); Assert.Throws <ArgumentException>(() => Range.Parse("-")); Assert.Throws <FormatException>(() => Range.Parse("InvalidNumber-6")); Assert.Throws <FormatException>(() => Range.Parse("6-InvalidNumber")); Assert.Throws <ArgumentOutOfRangeException>(() => Range.Parse("6-4")); Assert.Throws <ArgumentException>(() => Range.Parse("4,6")); }