You've already forked linux-packaging-mono
Imported Upstream version 3.8.0
Former-commit-id: 6a76a29bd07d86e57c6c8da45c65ed5447d38a61
This commit is contained in:
@@ -639,6 +639,62 @@ namespace MonoTests.System.ComponentModel
|
||||
|
||||
Assert.AreEqual (1, count, "1");
|
||||
}
|
||||
|
||||
private class Person : INotifyPropertyChanged
|
||||
{
|
||||
private string _lastName;
|
||||
private string _firstName;
|
||||
|
||||
public string FirstName {
|
||||
get { return _firstName; }
|
||||
set {
|
||||
_firstName = value;
|
||||
OnPropertyChanged ("FirstName"); // string matches property name
|
||||
}
|
||||
}
|
||||
|
||||
public string LastName {
|
||||
get { return _lastName; }
|
||||
set {
|
||||
_lastName = value;
|
||||
OnPropertyChanged ("Apepe"); // string doesn't match property name
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged (string propertyName = null)
|
||||
{
|
||||
PropertyChangedEventHandler handler = PropertyChanged;
|
||||
if (handler != null)
|
||||
handler (this, new PropertyChangedEventArgs (propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
[Test] // https://bugzilla.xamarin.com/show_bug.cgi?id=20672
|
||||
public void Bug20672 ()
|
||||
{
|
||||
string changedPropertyName = string.Empty;
|
||||
bool isEventRaised = false;
|
||||
bool? hasPropertyDescriptor = false;
|
||||
|
||||
var persons = new BindingList<Person>();
|
||||
persons.Add (new Person() { FirstName = "Stefaan", LastName = "de Vogelaere" });
|
||||
persons.Add (new Person() { FirstName = "Christophe", LastName = "De Langhe" });
|
||||
persons.ListChanged += (object sender, ListChangedEventArgs e) => {
|
||||
isEventRaised = true;
|
||||
hasPropertyDescriptor = e.PropertyDescriptor != null;
|
||||
};
|
||||
|
||||
//if the OnPropertyChanged string matches a valid property name, PropertyDescriptor should be generated
|
||||
persons[0].FirstName = "Stefan";
|
||||
Assert.IsTrue (isEventRaised);
|
||||
Assert.IsTrue ((bool) hasPropertyDescriptor, "#1");
|
||||
|
||||
//if the OnPropertyChanged string doesn't match a valid property name, no PropertyDescriptor should be generated
|
||||
persons[0].LastName = "de le Vulu";
|
||||
Assert.IsFalse ((bool) hasPropertyDescriptor, "#2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Net.Sockets
|
||||
{
|
||||
[TestFixture]
|
||||
public class SocketConnectAsyncTest
|
||||
{
|
||||
Socket serverSocket;
|
||||
Socket clientSocket;
|
||||
SocketAsyncEventArgs clientSocketAsyncArgs;
|
||||
ManualResetEvent readyEvent;
|
||||
ManualResetEvent mainEvent;
|
||||
Exception error;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
readyEvent = new ManualResetEvent (false);
|
||||
mainEvent = new ManualResetEvent (false);
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
readyEvent.Close ();
|
||||
mainEvent.Close ();
|
||||
}
|
||||
|
||||
void StartServer()
|
||||
{
|
||||
readyEvent.Reset();
|
||||
mainEvent.Reset();
|
||||
ThreadPool.QueueUserWorkItem (_ => DoWork ());
|
||||
readyEvent.WaitOne ();
|
||||
}
|
||||
|
||||
void StopServer()
|
||||
{
|
||||
if (serverSocket != null)
|
||||
serverSocket.Close ();
|
||||
}
|
||||
|
||||
void DoWork ()
|
||||
{
|
||||
serverSocket = new Socket (
|
||||
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
serverSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0));
|
||||
serverSocket.Listen (1);
|
||||
|
||||
var async = new SocketAsyncEventArgs ();
|
||||
async.Completed += (s,e) => OnAccepted (e);
|
||||
|
||||
readyEvent.Set ();
|
||||
|
||||
if (!serverSocket.AcceptAsync (async))
|
||||
OnAccepted (async);
|
||||
}
|
||||
|
||||
void OnAccepted (SocketAsyncEventArgs e)
|
||||
{
|
||||
var acceptSocket = e.AcceptSocket;
|
||||
mainEvent.Set ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category("Test")]
|
||||
public void Connect ()
|
||||
{
|
||||
StartServer();
|
||||
|
||||
EndPoint serverEndpoint = serverSocket.LocalEndPoint;
|
||||
|
||||
var m = new ManualResetEvent (false);
|
||||
var e = new SocketAsyncEventArgs ();
|
||||
|
||||
clientSocket = new Socket (
|
||||
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
clientSocketAsyncArgs = new SocketAsyncEventArgs();
|
||||
clientSocketAsyncArgs.RemoteEndPoint = serverEndpoint;
|
||||
clientSocketAsyncArgs.Completed += (s,o) => {
|
||||
if (o.SocketError != SocketError.Success)
|
||||
error = new SocketException ((int)o.SocketError);
|
||||
m.Set ();
|
||||
};
|
||||
bool res = clientSocket.ConnectAsync(clientSocketAsyncArgs);
|
||||
if (res) {
|
||||
if (!m.WaitOne (1500))
|
||||
throw new TimeoutException ();
|
||||
}
|
||||
|
||||
if (!mainEvent.WaitOne (1500))
|
||||
throw new TimeoutException ();
|
||||
if (error != null)
|
||||
throw error;
|
||||
|
||||
m.Reset ();
|
||||
mainEvent.Reset ();
|
||||
|
||||
StopServer();
|
||||
|
||||
// Try again to non-listening endpoint, expect error
|
||||
|
||||
error = null;
|
||||
clientSocket = new Socket (
|
||||
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
clientSocketAsyncArgs = new SocketAsyncEventArgs ();
|
||||
clientSocketAsyncArgs.RemoteEndPoint = serverEndpoint;
|
||||
clientSocketAsyncArgs.Completed += (s,o) => {
|
||||
if (o.SocketError != SocketError.Success)
|
||||
error = new SocketException ((int)o.SocketError);
|
||||
m.Set ();
|
||||
};
|
||||
res = clientSocket.ConnectAsync (clientSocketAsyncArgs);
|
||||
if (res) {
|
||||
if (!m.WaitOne (1500))
|
||||
throw new TimeoutException ();
|
||||
}
|
||||
|
||||
Assert.IsTrue (error != null, "Connect - no error");
|
||||
SocketException socketException = (SocketException)error;
|
||||
Assert.IsTrue(socketException.ErrorCode == (int)SocketError.ConnectionRefused);
|
||||
|
||||
m.Reset ();
|
||||
mainEvent.Reset ();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1 +1 @@
|
||||
0ae72b4c29ac57ce57fafde17a909f16b88df913
|
||||
b6ddbf164a5e04ef05fc2d35b59923c2f82abef6
|
@@ -74,6 +74,13 @@ namespace MonoTests.System.Net.Sockets {
|
||||
//Assert.AreEqual (32, client.Ttl, "#A:Ttl");
|
||||
#endif
|
||||
|
||||
#if NET_2_0
|
||||
if (!Socket.OSSupportsIPv6)
|
||||
#else
|
||||
if (!Socket.SupportsIPv6)
|
||||
#endif
|
||||
Assert.Ignore ("IPv6 not enabled.");
|
||||
|
||||
client = new MyUdpClient (AddressFamily.InterNetworkV6);
|
||||
s = client.Client;
|
||||
Assert.IsNotNull (s, "#B:Client");
|
||||
@@ -297,6 +304,13 @@ namespace MonoTests.System.Net.Sockets {
|
||||
Assert.AreEqual (AddressFamily.InterNetwork, localEP.AddressFamily, "#A:Client:LocalEndPoint/AddressFamily");
|
||||
}
|
||||
|
||||
#if NET_2_0
|
||||
if (!Socket.OSSupportsIPv6)
|
||||
#else
|
||||
if (!Socket.SupportsIPv6)
|
||||
#endif
|
||||
Assert.Ignore ("IPv6 not enabled.");
|
||||
|
||||
using (MyUdpClient client = new MyUdpClient (IPEndPoint.MaxPort, AddressFamily.InterNetworkV6))
|
||||
{
|
||||
s = client.Client;
|
||||
@@ -656,6 +670,13 @@ namespace MonoTests.System.Net.Sockets {
|
||||
[Test] // JoinMulticastGroup (Int32, IPAddress)
|
||||
public void JoinMulticastGroup2_Socket_Closed ()
|
||||
{
|
||||
#if NET_2_0
|
||||
if (!Socket.OSSupportsIPv6)
|
||||
#else
|
||||
if (!Socket.SupportsIPv6)
|
||||
#endif
|
||||
Assert.Ignore ("IPv6 not enabled.");
|
||||
|
||||
IPAddress mcast_addr = null;
|
||||
|
||||
UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234));
|
||||
|
@@ -28,8 +28,8 @@ namespace MonoTests.System.Net
|
||||
[TestFixture]
|
||||
public class DnsTest
|
||||
{
|
||||
private String site1Name = "mono-project.com",
|
||||
site1Dot = "96.126.105.110",
|
||||
private String site1Name = "xamarin.com",
|
||||
site1Dot = "50.19.126.231",
|
||||
site2Name = "info.diku.dk",
|
||||
site2Dot = "130.225.96.4",
|
||||
noneExistingSite = "unlikely.xamarin.com";
|
||||
@@ -44,7 +44,7 @@ namespace MonoTests.System.Net
|
||||
IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);
|
||||
IPHostEntry entry = Dns.EndGetHostByName (async);
|
||||
SubTestValidIPHostEntry (entry);
|
||||
Assert.IsTrue (entry.HostName == "www.mono-project.com" || entry.HostName == "mono-project.com");
|
||||
Assert.IsTrue (entry.HostName == "www.xamarin.com" || entry.HostName == "xamarin.com");
|
||||
}
|
||||
|
||||
void GetHostByNameCallback (IAsyncResult ar)
|
||||
@@ -191,7 +191,7 @@ namespace MonoTests.System.Net
|
||||
[Test]
|
||||
public void GetHostByName ()
|
||||
{
|
||||
SubTestGetHostByName ("www.mono-project.com", site1Dot);
|
||||
SubTestGetHostByName ("www.xamarin.com", site1Dot);
|
||||
SubTestGetHostByName (site2Name, site2Dot);
|
||||
try {
|
||||
var entry = Dns.GetHostByName (noneExistingSite);
|
||||
|
@@ -144,7 +144,7 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "GET / HTTP/1.1\r\n\r\n"); // No host
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -155,7 +155,7 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); // no prefix
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -192,7 +192,7 @@ namespace MonoTests.System.Net {
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
listener.Close ();
|
||||
Assert.AreEqual (true, response.StartsWith ("HTTP/1.1 400"), String.Format ("Failed on {0}", (int) b));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", response, String.Format ("Failed on {0}", (int) b));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "POST /test4/ HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); // length required
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 411"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 411", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -215,7 +215,7 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "POST / HTTP/1.1\r\nHost: 127.0.0.1\r\nTransfer-Encoding: pepe\r\n\r\n"); // not implemented
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 501"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 501", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -227,7 +227,7 @@ namespace MonoTests.System.Net {
|
||||
Send (ns, "POST /test6/ HTTP/1.1\r\nHost: 127.0.0.1\r\nTransfer-Encoding: identity\r\n\r\n");
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 501"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 501", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -241,8 +241,8 @@ namespace MonoTests.System.Net {
|
||||
ctx.Response.Close ();
|
||||
string response = Receive (ns, 1024);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 200"));
|
||||
Assert.IsTrue (-1 != response.IndexOf ("Transfer-Encoding: chunked"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 200", response);
|
||||
StringAssert.Contains ("Transfer-Encoding: chunked", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -257,7 +257,7 @@ namespace MonoTests.System.Net {
|
||||
ctx.Response.Close ();
|
||||
string response = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 200"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 200", response);
|
||||
Assert.IsTrue (-1 == response.IndexOf ("Transfer-Encoding: chunked"));
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace MonoTests.System.Net {
|
||||
string response = ReceiveWithTimeout (ns, 512, 1000, out timeout);
|
||||
ns.Close ();
|
||||
Assert.IsFalse (timeout);
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 411"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 411", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -287,7 +287,7 @@ namespace MonoTests.System.Net {
|
||||
string response = ReceiveWithTimeout (ns, 512, 1000, out timeout);
|
||||
ns.Close ();
|
||||
Assert.IsFalse (timeout);
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 411"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 411", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -300,7 +300,7 @@ namespace MonoTests.System.Net {
|
||||
ns.GetSocket ().Shutdown (SocketShutdown.Send);
|
||||
string input = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (input.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", input);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -313,7 +313,7 @@ namespace MonoTests.System.Net {
|
||||
ns.GetSocket ().Shutdown (SocketShutdown.Send);
|
||||
string input = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (input.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", input);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -326,7 +326,7 @@ namespace MonoTests.System.Net {
|
||||
ns.GetSocket ().Shutdown (SocketShutdown.Send);
|
||||
string input = Receive (ns, 512);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (input.StartsWith ("HTTP/1.1 400"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 400", input);
|
||||
}
|
||||
|
||||
HttpListenerRequest test14_request;
|
||||
@@ -418,8 +418,8 @@ namespace MonoTests.System.Net {
|
||||
ctx.Response.Close ();
|
||||
string response = Receive (ns, 1024);
|
||||
ns.Close ();
|
||||
Assert.IsTrue (response.StartsWith ("HTTP/1.1 200"));
|
||||
Assert.IsTrue (-1 != response.IndexOf ("Transfer-Encoding: chunked"));
|
||||
StringAssert.StartsWith ("HTTP/1.1 200", response);
|
||||
StringAssert.Contains ("Transfer-Encoding: chunked", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -723,11 +723,11 @@ namespace MonoTests.System.Net {
|
||||
public void ClosePort ()
|
||||
{
|
||||
var h = new HttpListener ();
|
||||
h.Prefixes.Add ("http://127.0.0.1:8080/");
|
||||
h.Prefixes.Add ("http://127.0.0.1:30158/");
|
||||
h.Start ();
|
||||
h.BeginGetContext (null, null);
|
||||
h.Stop ();
|
||||
TcpListener t = new TcpListener (IPAddress.Parse ("127.0.0.1"), 8080);
|
||||
TcpListener t = new TcpListener (IPAddress.Parse ("127.0.0.1"), 30158);
|
||||
t.Start ();
|
||||
t.Stop ();
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
f0826d1c9902938fe975f2a12554f06926ef5876
|
||||
ccf2484dfdddf2db7e554b5b4176c004fc9f9a94
|
@@ -2156,5 +2156,97 @@ namespace MonoTests.System.Net
|
||||
// and return the same instance as WebRequest.DefaultWebProxy
|
||||
Assert.AreSame (wc.Proxy, WebRequest.DefaultWebProxy);
|
||||
}
|
||||
|
||||
#if NET_4_5
|
||||
[Test]
|
||||
public void UploadStringAsyncCancelEvent ()
|
||||
{
|
||||
UploadAsyncCancelEventTest ((webClient, uri, cancelEvent) =>
|
||||
{
|
||||
|
||||
webClient.UploadStringCompleted += (sender, args) =>
|
||||
{
|
||||
if (args.Cancelled)
|
||||
cancelEvent.Set ();
|
||||
};
|
||||
|
||||
webClient.UploadStringAsync (uri, "PUT", "text");
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UploadDataAsyncCancelEvent ()
|
||||
{
|
||||
UploadAsyncCancelEventTest ((webClient, uri, cancelEvent) =>
|
||||
{
|
||||
webClient.UploadDataCompleted += (sender, args) =>
|
||||
{
|
||||
if (args.Cancelled)
|
||||
cancelEvent.Set ();
|
||||
};
|
||||
|
||||
webClient.UploadDataAsync (uri, "PUT", new byte[] { });
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UploadValuesAsyncCancelEvent ()
|
||||
{
|
||||
UploadAsyncCancelEventTest ((webClient, uri, cancelEvent) =>
|
||||
{
|
||||
webClient.UploadValuesCompleted += (sender, args) =>
|
||||
{
|
||||
if (args.Cancelled)
|
||||
cancelEvent.Set ();
|
||||
};
|
||||
|
||||
webClient.UploadValuesAsync (uri, "PUT", new NameValueCollection ());
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UploadFileAsyncCancelEvent ()
|
||||
{
|
||||
UploadAsyncCancelEventTest ((webClient, uri, cancelEvent) =>
|
||||
{
|
||||
string tempFile = Path.Combine (_tempFolder, "upload.tmp");
|
||||
File.Create (tempFile).Close ();
|
||||
|
||||
webClient.UploadFileCompleted += (sender, args) =>
|
||||
{
|
||||
if (args.Cancelled)
|
||||
cancelEvent.Set ();
|
||||
};
|
||||
|
||||
webClient.UploadFileAsync (uri, "PUT", tempFile);
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NET_4_0
|
||||
public void UploadAsyncCancelEventTest (Action<WebClient, Uri, EventWaitHandle> uploadAction)
|
||||
{
|
||||
var ep = new IPEndPoint (IPAddress.Loopback, 8000);
|
||||
string url = "http://" + IPAddress.Loopback + ":8000/test/";
|
||||
|
||||
using (var responder = new SocketResponder (ep, EchoRequestHandler))
|
||||
{
|
||||
responder.Start ();
|
||||
|
||||
var webClient = new WebClient ();
|
||||
|
||||
var cancellationTokenSource = new CancellationTokenSource ();
|
||||
cancellationTokenSource.Token.Register (webClient.CancelAsync);
|
||||
|
||||
var cancelEvent = new ManualResetEvent (false);
|
||||
|
||||
uploadAction.Invoke (webClient, new Uri (url), cancelEvent);
|
||||
|
||||
cancellationTokenSource.Cancel ();
|
||||
|
||||
Assert.IsTrue (cancelEvent.WaitOne (1000));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
19a7c19f82126a787143c28fdb89daf1b66116bb
|
||||
9fceaca05cac364bf580c8b503efd8b7f5465e22
|
Reference in New Issue
Block a user