Пример #1
0
        public void TryParseExact()
        {
            Comb c;

            Assert.IsTrue(Comb.TryParseExact("{0x3e3a6e75,0x0100,0x0f45,{0xae,0x41,0xa3,0xe3,0xd2,0x53,0x6a,0x57}}", "X", out c));
            Assert.IsTrue(Comb.TryParseExact("{0x3E3A6E75,0x0100,0x0F45,{0xAE,0x41,0xA3,0xE3,0xD2,0x53,0x6A,0x57}}", "x", out c));

            Assert.IsTrue(Comb.TryParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "N", out c));
            Assert.IsTrue(Comb.TryParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "n", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "n", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-01000f45ae41a3e3d2536a57", "n", out c));
            //Assert.IsFalse(Comb.TryParseExact("3e3a6e750100-0f45ae41a3e3d2536a57", "n", out c));
            //Assert.IsFalse(Comb.TryParseExact("3e3a6e7501000f45-ae41a3e3d2536a57", "n", out c));
            //Assert.IsFalse(Comb.TryParseExact("3e3a6e7501000f45ae41-a3e3d2536a57", "n", out c));

            Assert.IsTrue(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "D", out c));
            Assert.IsTrue(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "d", out c));
            Assert.IsTrue(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e7501000f45ae41a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-01000f45ae41a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45ae41a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "d", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "d", out c));

            Assert.IsTrue(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "B", out c));
            Assert.IsTrue(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57}", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-01000f45ae41a3e3d2536a57}", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-0100-0f45ae41a3e3d2536a57}", "b", out c));
            Assert.IsFalse(Comb.TryParseExact("{3e3a6e75-0100-0f45-ae41a3e3d2536a57}", "b", out c));

            Assert.IsTrue(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "P", out c));
            Assert.IsTrue(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-01000f45ae41a3e3d2536a57)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-0100-0f45ae41a3e3d2536a57)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41a3e3d2536a57)", "p", out c));

            Assert.IsFalse(Comb.TryParseExact(null, "d", out c));
            Assert.IsFalse(Comb.TryParseExact("(00000000000000000000000000000000)", "p", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a57", "x", out c));

            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a573e", "x", out c));
            Assert.IsFalse(Comb.TryParseExact("3e3a6e75-0100-0f45-ae41-a3e3d2536a", "x", out c));

            ExceptionAssert.Throws <FormatException>(() => Comb.TryParseExact("(3e3a6e75-0100-0f45-ae41-a3e3d2536a57)", "e", out c));
        }