1 // UnixEndPointTest.cs: Unit tests for Mono.Unix.UnixListener
4 // David Lechner (david@lechnology.com)
6 // (c) 2015 David Lechner
12 using System.Net.Sockets;
15 using NUnit.Framework;
18 namespace MonoTests.Mono.Unix {
21 public class UnixEndPointTest {
23 // Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=35004
25 public void TestCreate ()
27 const string socketFile = "test";
28 // mangledSocketFile simulates the socket file name with a null
29 // terminator and junk after the null terminator. This can be present
30 // in a SocketAddress when marshaled from native code.
31 const string mangledSocketFile = socketFile + "\0junk";
33 var bytes = Encoding.Default.GetBytes (mangledSocketFile);
34 var socketAddress = new SocketAddress (AddressFamily.Unix, bytes.Length + 2);
35 for (int i = 0; i < bytes.Length; i++) {
36 socketAddress [i + 2] = bytes [i];
38 var dummyEndPoint = new UnixEndPoint (socketFile);
40 // testing that the Create() method strips off the null terminator and the junk
41 var endPoint = (UnixEndPoint)dummyEndPoint.Create (socketAddress);
42 Assert.AreEqual (socketFile, endPoint.Filename, "#A01");