Example #1
0
        public void TestCreate ()
        {
            const string socketFile = "test";
            // mangledSocketFile simulates the socket file name with a null
            // terminator and junk after the null terminator. This can be present
            // in a SocketAddress when marshaled from native code.
            const string mangledSocketFile = socketFile + "\0junk";

            var bytes = Encoding.Default.GetBytes (mangledSocketFile);
            var socketAddress = new SocketAddress (AddressFamily.Unix, bytes.Length + 2);
            for (int i = 0; i < bytes.Length; i++) {
                socketAddress [i + 2] = bytes [i];
            }
            var dummyEndPoint = new UnixEndPoint (socketFile);

            // testing that the Create() method strips off the null terminator and the junk
            var endPoint = (UnixEndPoint)dummyEndPoint.Create (socketAddress);
            Assert.AreEqual (socketFile, endPoint.Filename, "#A01");
        }