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 IsInRange_InRange_ReturnsTrue() { var r1 = new Range <double>(5, 10); var r2 = new Range <double>(6, 10); Assert.True(r1.IsInRange(r2)); }
public void IsInRange_NotInRange_ReturnsFalse() { var r1 = new Range <double>(5, 10); var r2 = new Range <double>(6, 10); Assert.False(r2.IsInRange(r1)); }
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 Range_Minus_ClassImplementingMinus() { var r = Range.FromPoint(new ClassWithMinusOperatorOverloading()); Assert.DoesNotThrow(() => { var i = r.Length; }); }
public void Range_Equals() { var r1 = new Range <double>(5, 10); var r2 = new Range <double>(5, 10); Assert.That(r1, Is.EqualTo(r2)); Assert.True(r1 == r2); Assert.True(Equals(r1, r2)); Assert.That(r1.GetHashCode(), Is.EqualTo(r2.GetHashCode())); }
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")); }
public void Range_NotEquals() { var r1 = new Range <double>(5, 10); var r2 = new Range <double>(6, 10); Assert.That(r1, Is.Not.EqualTo(r2)); Assert.True(r1 != r2); Assert.False(Equals(r1, r2)); Assert.False(r1.Equals(null)); Assert.That(r1, Is.Not.EqualTo(null)); Assert.False(r1.Equals(5)); Assert.That(r1.GetHashCode(), Is.Not.EqualTo(r2.GetHashCode())); }
public void Length([Values(1, 2, 3, 4, 5)] double length) { var r = new Range <double>(0, length); Assert.AreEqual(r.Length, length); }
public void IsInRange_SameRange_ReturnsTrue() { var r1 = new Range <double>(5, 10); Assert.True(r1.IsInRange(r1)); }
public void IsInRange_OutOfRange_False([Values(1, 2, 3, 4, 5)] double value) { var r = new Range <double>(6, 10); Assert.IsFalse(r.IsInRange(value)); }
public void IsInRange_InRange_True([Values(1, 2, 3, 4, 5)] double value) { var r = new Range <double>(1, 100); Assert.IsTrue(r.IsInRange(value)); }
public void Range_ToString() { var r = new Range <double>(7, 11); Assert.That(r.ToString(), Is.EqualTo("7-11")); }
public void Range_SinglePoint() { var r = Range.FromPoint(5); Assert.That(r.From, Is.EqualTo(r.To)); }
public void Range_Minus_ClassNotImplementingMinus_ThrowsRuntimeBinderException() { var r = Range.FromPoint(new ClassWithoutMinusOperatorOverloading()); Assert.That(() => r.Length, Throws.TypeOf <RuntimeBinderException>()); }
public void Range_FromPoint_ToString() { var r = Range.FromPoint <double>(5); Assert.That(r.ToString(), Is.EqualTo("5-5")); }