public void ToByteArray() { var c = Comb.Parse("385175e2-0b00-b248-911d-413fa76b7979"); var a = c.ToByteArray(); Assert.IsNotNull(a); Assert.AreEqual(16, a.Length); CollectionAssert.AllItemsAreNotNull(a); CollectionAssert.AreEqual(new byte[] { 56, 81, 117, 226, 11, 0, 178, 72, 145, 29, 65, 63, 167, 107, 121, 121 }, a); }
public void Parse() { Assert.IsInstanceOfType(Comb.Parse("{0x3e3a6e75,0x0100,0x0f45,{0xae,0x41,0xa3,0xe3,0xd2,0x53,0x6a,0x57}}"), typeof(Comb)); Assert.IsInstanceOfType(Comb.Parse("{0x3E3A6E75,0x0100,0x0F45,{0xAE,0x41,0xA3,0xE3,0xD2,0x53,0x6A,0x57}}"), typeof(Comb)); Assert.IsInstanceOfType(Comb.Parse("3e3a6e7501000f45ae41a3e3d2536a57"), typeof(Comb)); Assert.IsInstanceOfType(Comb.Parse("3e3a6e75-0100-0f45-ae41-a3e3d2536a57"), typeof(Comb)); Assert.IsInstanceOfType(Comb.Parse("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}"), typeof(Comb)); Assert.IsInstanceOfType(Comb.Parse("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)"), typeof(Comb)); ExceptionAssert.Throws <ArgumentNullException>(() => Comb.Parse(null)); ExceptionAssert.Throws <FormatException>(() => Comb.Parse("(00000000000000000000000000000000)")); }
public void ParseExact() { Assert.IsInstanceOfType(Comb.ParseExact("{0x3e3a6e75,0x0100,0x0f45,{0xae,0x41,0xa3,0xe3,0xd2,0x53,0x6a,0x57}}", "X"), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("{0x3E3A6E75,0x0100,0x0F45,{0xAE,0x41,0xA3,0xE3,0xD2,0x53,0x6A,0x57}}", "x"), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "N"), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "n"), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "D"), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "d"), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", ""), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "B"), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "b"), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "P"), typeof(Comb)); Assert.IsInstanceOfType(Comb.ParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "p"), typeof(Comb)); Assert.ThrowsException<ArgumentNullException>(() => Comb.Parse(null)); Assert.ThrowsException<FormatException>(() => Comb.Parse("(00000000000000000000000000000000)")); Assert.ThrowsException<FormatException>(() => Comb.ParseExact("3e3a6e75-0100-0f45-ae41a3e3d2536a57", "x")); }
public void Equality() { var left = Comb.NewComb(); var right = Comb.NewComb(); Assert.IsTrue(left != right); Assert.IsFalse(left == right); right = left; Assert.IsTrue(left == right); Assert.IsTrue(left.Equals(right)); Assert.IsTrue(left.Equals((object)right)); Assert.IsFalse(left.Equals(null)); Assert.IsFalse(left.Equals("test")); var hash = Comb.Parse("385175e2-0b00-b248-911d-413fa76b7979"); Assert.AreEqual(1917962195, hash.GetHashCode()); Assert.AreEqual(left.GetHashCode(), right.GetHashCode()); Assert.AreNotEqual(left.GetHashCode(), hash.GetHashCode()); }