public void SimpleTest() { Assert.AreEqual <SerialNumber32>(1, 1); Assert.AreNotEqual <SerialNumber32>(1, 2); MoreAssert.IsBigger(1, 2); MoreAssert.IsSmaller(2, 1); SerialNumber32 serialNumber = 1; serialNumber = serialNumber.Add(10); Assert.AreEqual <SerialNumber32>(11, serialNumber); serialNumber = serialNumber.Add(((uint)1 << 31) - 1); Assert.AreEqual <SerialNumber32>(2147483658, serialNumber); MoreAssert.IsSmaller <SerialNumber32>(1, serialNumber); MoreAssert.IsBigger <SerialNumber32>(20, serialNumber); serialNumber = serialNumber.Add(((uint)1 << 31) - 1); Assert.AreEqual <SerialNumber32>(9, serialNumber); Assert.IsTrue(new SerialNumber32(1) < new SerialNumber32(2)); Assert.IsTrue(new SerialNumber32(2) > new SerialNumber32(1)); // ReSharper disable EqualExpressionComparison Assert.IsFalse(new SerialNumber32(1) < new SerialNumber32(1)); Assert.IsFalse(new SerialNumber32(1) > new SerialNumber32(1)); // ReSharper restore EqualExpressionComparison Assert.IsTrue(new SerialNumber32(2) != new SerialNumber32(1)); Assert.IsFalse(new SerialNumber32(1) != new SerialNumber32(0).Add(1)); Assert.IsTrue(new SerialNumber32(2) == new SerialNumber32(1).Add(1)); Assert.IsFalse(new SerialNumber32(1).Equals(1.0)); Assert.AreEqual("1", new SerialNumber32(1).ToString()); }
public void OverflowAddTest() { SerialNumber32 serialNumber = 1; serialNumber = serialNumber.Add((uint)1 << 31); Assert.Fail(serialNumber.ToString()); }