| using System;
using NUnit.Framework;
[TestFixture]
public class IntervalTest{
Interval iv_1, iv_2, iv_3, iv_4;
[SetUp]
public void Init(){
iv_1 = new Interval(3,8);
iv_2 = new Interval(8,3);
iv_3 = new Interval(3,3);
iv_4 = Interval.MakeEmptyInterval();
}
[Test]
public void FromTest1(){
Assert.AreEqual(3, iv_1.From, "Fromtest: Positive orientation");
}
[Test]
public void FromTest2(){
Assert.AreEqual(8, iv_2.From, "Fromtest: Negative orientation");
}
[Test]
public void FromTest3(){
Assert.AreEqual(3, iv_3.From, "Fromtest: Singleton");
}
[Test, ExpectedException("IntervalAccessException")]
public void FromTestEmpty(){
int res = iv_4.From;
}
[Test]
public void ToTest1(){
Assert.AreEqual(8, iv_1.To, "ToTest: Positive orientation");
}
[Test]
public void ToTest2(){
Assert.AreEqual(3, iv_2.To, "ToTest: Negative orientation");
}
[Test]
public void ToTest3(){
Assert.AreEqual(3, iv_3.To, "ToTest: Singleton");
}
[Test, ExpectedException("IntervalAccessException")]
public void ToTestEmpty(){
int res = iv_4.To;
}
[Test]
public void LengthTest1(){
Assert.AreEqual(6, iv_1.Length, "Length positive orientation");
}
[Test]
public void LengthTest2(){
Assert.AreEqual(6, iv_2.Length, "Length negative orientation");
}
[Test]
public void LengthTest3(){
Assert.AreEqual(1, iv_3.Length, "Length singleton");
}
[Test]
public void LengthTest4(){
Assert.AreEqual(0, iv_4.Length, "Length empty");
}
[Test]
public void EmptyTest1(){
Assert.IsFalse(iv_1.Empty, "Empty positive orientation");
}
[Test]
public void EmptyTest2(){
Assert.IsFalse(iv_2.Empty, "Empty negative orientation");
}
[Test]
public void EmptyTest3(){
Assert.IsFalse(iv_3.Empty, "Empty singleton");
}
[Test]
public void EmptyTest4(){
Assert.IsTrue(iv_4.Empty, "Empty - Empty");
}
[Test]
public void PlusTest1(){
Interval iv = new Interval(3,5);
Assert.AreEqual((iv+3).From, 6, "Plus - Interval + integer - From limit");
}
[Test]
public void PlusTest2(){
Interval iv = new Interval(3,5);
Assert.AreEqual((iv+3).To, 8, "Plus - Interval + integer - From limit");
}
[Test]
public void PlusTest3(){
Interval iv = new Interval(3,5);
Assert.AreEqual((3+iv).From, 6, "Plus - integer + Interval - From limit");
}
[Test]
public void PlusTest4(){
Interval iv = new Interval(3,5);
Assert.AreEqual((3+iv).To, 8, "Plus - integer + Interval - To limit");
}
} |