Example #1
0
        public void Xid_Parse_ParsesXidToStringToSameValueXid()
        {
            var x = Xid.NewXid();
            var y = Xid.Parse(x.ToString());

            Assert.AreEqual(x, y);
        }
Example #2
0
        public void Xid_CompareToObj_ReturnsZeroWhenEqual()
        {
            var x = Xid.NewXid();
            var y = Xid.Parse(x.ToString());

            Assert.AreEqual(0, y.CompareTo((object)x));
        }
Example #3
0
        public void Xid_TryParse_ParsesValidXid()
        {
            var s  = "9m4e2mr0ui3e8a215n4g";
            var ok = Xid.TryParse(s, out Xid x);

            Assert.IsTrue(ok);
            Assert.AreEqual(Xid.Parse(s), x);
        }
        public void Xid_ToString_ParsesBackToOriginalValue()
        {
            var x = Xid.NewXid();
            var s = x.ToString();
            var y = Xid.Parse(s);

            Assert.AreEqual(x, y);
        }
Example #5
0
        public void Xid_GetHashCode_EqualCodesForEqualValues()
        {
            var maxIterations = 1000000;

            for (int cnt = 0; cnt < maxIterations; cnt++)
            {
                var x = Xid.NewXid();
                var y = Xid.Parse(x.ToString());
                Assert.AreEqual(x.GetHashCode(), y.GetHashCode());
            }
        }
Example #6
0
        public void Xid_Parse_ParsesValueToExpectedBytes()
        {
            var x = Xid.Parse("9m4e2mr0ui3e8a215n4g");
            var y = new Xid(new byte[] { 0x4d, 0x88, 0xe1, 0x5b, 0x60, 0xf4, 0x86, 0xe4, 0x28, 0x41, 0x2d, 0xc9 });

            Assert.AreEqual(x, y);
            Assert.AreEqual("9m4e2mr0ui3e8a215n4g", y.ToString());
            Assert.AreEqual(4271561, x.GetCounter());
            Assert.AreEqual(63436413019, x.GetTimestamp().Subtract(DateTime.MinValue).TotalSeconds);
            Assert.AreEqual(0xe428, x.GetProcessId());
        }
Example #7
0
        public void Xid_Parse_ThrowsOnInvalidCharacters()
        {
            var y = Xid.Parse("9m4e2mrZui3e8a215n4g");

            Assert.Fail();
        }
Example #8
0
        public void Xid_Parse_ThrowsOnLongString()
        {
            var y = Xid.Parse("9m4e2mr0ui3e8a215n4g9m4e2mr0ui3e8a215n4g");

            Assert.Fail();
        }
Example #9
0
        public void Xid_Parse_ThrowsOnShortString()
        {
            var y = Xid.Parse("9m4e2mr");

            Assert.Fail();
        }
Example #10
0
        public void Xid_Parse_ThrowsOnEmptyString()
        {
            var y = Xid.Parse(String.Empty);

            Assert.Fail();
        }
Example #11
0
        public void Xid_Parse_ThrowsOnNullString()
        {
            var y = Xid.Parse(null);

            Assert.Fail();
        }