public void It_handles_Int16_identifiers() { var helper = new IdHelperForValueType <short>(); helper.IsDefaultValue(0).ShouldBeTrue(); helper.IsDefaultValue(1).ShouldBeFalse(); helper.AreEqual(0, 0).ShouldBeTrue(); helper.AreEqual(23, 23).ShouldBeTrue(); helper.Compare(0, 1).ShouldBe(-1); helper.Compare(0, -1).ShouldBe(1); helper.Compare(0, 0).ShouldBe(0); helper.Compare(23, 23).ShouldBe(0); helper.GetHashCode(0).ShouldBe(((short)0).GetHashCode()); helper.GetHashCode(23).ShouldBe(((short)23).GetHashCode()); }
public void Value_type_short() { var helper = new IdHelperForValueType<short>(); Assert.AreEqual(false, helper.IsNull(0)); Assert.AreEqual(true, helper.IsDefaultValue(0)); Assert.AreEqual(false, helper.IsDefaultValue(1)); Assert.AreEqual(true, helper.AreEqual(0, 0)); Assert.AreEqual(true, helper.AreEqual(23, 23)); Assert.AreEqual(-1, helper.Compare(0, 1)); Assert.AreEqual(+1, helper.Compare(0, -1)); Assert.That(helper.Compare(0, 0), Is.EqualTo(0)); Assert.AreEqual(0, helper.Compare(23, 23)); Assert.AreEqual(0.GetHashCode(), helper.GetHashCode(0)); Assert.AreEqual(((short)23).GetHashCode(), helper.GetHashCode(23)); }
public void It_handles_Guid_identifiers() { var helper = new IdHelperForValueType <Guid>(); var guid1 = new Guid("005faa88-a529-4065-9d04-72a96316988b"); var guid2 = new Guid("64b9dd7a-f46e-448b-b6e5-ddd3f83ec508"); helper.IsDefaultValue(Guid.Empty).ShouldBeTrue(); helper.IsDefaultValue(guid1).ShouldBeFalse(); helper.AreEqual(Guid.Empty, Guid.Empty).ShouldBeTrue(); helper.AreEqual(guid1, guid1).ShouldBeTrue(); helper.Compare(Guid.Empty, guid1).ShouldBe(-1); helper.Compare(guid2, Guid.Empty).ShouldBe(1); helper.Compare(Guid.Empty, Guid.Empty).ShouldBe(0); helper.Compare(guid2, guid2).ShouldBe(0); helper.GetHashCode(Guid.Empty).ShouldBe(Guid.Empty.GetHashCode()); helper.GetHashCode(guid1).ShouldBe(guid1.GetHashCode()); }
public void Value_type_Guid() { var helper = new IdHelperForValueType<Guid>(); var guid1 = new Guid("005faa88-a529-4065-9d04-72a96316988b"); var guid2 = new Guid("64b9dd7a-f46e-448b-b6e5-ddd3f83ec508"); Assert.AreEqual(false, helper.IsNull(Guid.Empty)); Assert.AreEqual(true, helper.IsDefaultValue(Guid.Empty)); Assert.AreEqual(false, helper.IsDefaultValue(guid1)); Assert.AreEqual(true, helper.AreEqual(Guid.Empty, Guid.Empty)); Assert.AreEqual(true, helper.AreEqual(guid1, guid1)); Assert.AreEqual(-1, helper.Compare(Guid.Empty, guid1)); Assert.AreEqual(+1, helper.Compare(guid2, Guid.Empty)); Assert.That(helper.Compare(Guid.Empty, Guid.Empty), Is.EqualTo(0)); Assert.AreEqual(0, helper.Compare(guid2, guid2)); Assert.AreEqual(Guid.Empty.GetHashCode(), helper.GetHashCode(Guid.Empty)); Assert.AreEqual(guid1.GetHashCode(), helper.GetHashCode(guid1)); }