Exemple #1
0
        public void GetIPText_Exception_NulllReference_Test()
        {
            byte[] data   = null;
            string actual = IPUtil.GetIPText(data);

            Assert.AreEqual(actual, string.Empty);
        }
Exemple #2
0
        public void GetIPText_Exception_IndexOutOfRange_Test()
        {
            byte[] data     = new byte[] { 127, 0, 0 };
            string actual   = IPUtil.GetIPText(data);
            string expected = "";

            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        public void GetIPTextTest()
        {
            byte[] data     = new byte[] { 127, 0, 0, 1 };
            string expected = "127.0.0.1";
            string actual;

            actual = IPUtil.GetIPText(data);
            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        public void GetIPTextTest1()
        {
            byte[] data     = new byte[] { 127, 0, 0, 1 };
            int    start    = 0;
            string expected = "127.0.0.1";
            string actual;

            actual = IPUtil.GetIPText(data, start);
            Assert.AreEqual(expected, actual);
            //验证抛出异常的情况
            try
            {
                start  = 1;
                actual = IPUtil.GetIPText(data, start);
                Assert.AreEqual(expected, actual);
            }
            catch (Exception)
            {
                Assert.IsFalse(false);
            }
        }