public void EqualsTest() { var id = UnifiedId.Parse("FVVVVVVVVVVVV"); Assert.True(id.Equals("FVVVVVVVVVVVV")); Assert.True(id.Equals(ulong.MaxValue)); Assert.True(id.Equals(id.ToInt64())); Assert.True(id.Equals(id)); Assert.True(id.Equals((object)"FVVVVVVVVVVVV")); Assert.True(id.Equals((object)ulong.MaxValue)); Assert.True(id.Equals((object)id.ToInt64())); Assert.True(id.Equals((object)id)); Assert.False(id.Equals(new object())); Assert.True(id == "FVVVVVVVVVVVV"); Assert.True(id == ulong.MaxValue); Assert.True(id == id.ToInt64()); Assert.True(id == new UnifiedId(id.ToUInt64())); Assert.False(id != "FVVVVVVVVVVVV"); Assert.False(id != ulong.MaxValue); Assert.False(id != id.ToInt64()); Assert.False(id != new UnifiedId(id.ToUInt64())); Assert.True("FVVVVVVVVVVVV" == id); Assert.True(ulong.MaxValue == id); Assert.True(id.ToInt64() == id); Assert.True(new UnifiedId(id.ToUInt64()) == id); Assert.False("FVVVVVVVVVVVV" != id); Assert.False(ulong.MaxValue != id); Assert.False(id.ToInt64() != id); Assert.False(new UnifiedId(id.ToUInt64()) != id); }
public void ParseTest() { var id = new UnifiedId("FVVVVVVVVVVVU"); var parsedId = UnifiedId.Parse(id); Assert.Equal(id, parsedId); Assert.Equal(UnifiedId.Empty, UnifiedId.Parse(string.Empty)); Assert.Throws <FormatException>(() => UnifiedId.Parse("VVVVVVVVVVVVV")); Assert.Throws <FormatException>(() => UnifiedId.Parse("FVVVVVVVVVVVUN")); Assert.Throws <FormatException>(() => UnifiedId.Parse("FVVVVVVVVVVVu")); Assert.Throws <FormatException>(() => UnifiedId.Parse("FVVVVVVVVVVVW")); Assert.Throws <FormatException>(() => UnifiedId.Parse("GVVVVVVVVVVVU")); Assert.Throws <FormatException>(() => UnifiedId.Parse("WVVVVVVVVVVVU")); }