Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -1,119 +0,0 @@
//
// BinaryMessageFormatterTest.cs -
// NUnit Test Cases for BinaryMessageFormatter
//
// Author:
// Michael Barker <mike@middlesoft.co.uk>
//
// Copyright (C) 2008 Michael Barker
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using System.Messaging;
using Mono.Messaging;
using NUnit.Framework;
using NUnit.Mocks;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class BinaryMessageFormatterTest
{
DynamicMock mock1;
IMessage msg1;
DynamicMock mock2;
IMessage msg2;
[SetUp]
public void SetUp ()
{
mock1 = new DynamicMock (typeof (IMessage));
msg1 = (IMessage) mock1.MockInstance;
mock2 = new DynamicMock (typeof (IMessage));
msg2 = (IMessage) mock2.MockInstance;
}
[Test]
public void FormatString ()
{
string s = "this is a test string";
Stream ms = new MemoryStream ();
mock1.ExpectAndReturn ("get_BodyStream", ms);
mock1.ExpectAndReturn ("get_BodyStream", ms);
mock1.Expect ("set_BodyType", 768);
mock2.ExpectAndReturn ("get_BodyStream", ms);
mock2.ExpectAndReturn ("get_BodyStream", ms);
Message m = TestUtils.CreateMessage (msg1);
m.Formatter = new BinaryMessageFormatter ();
m.Formatter.Write (m, s);
Stream stream = m.BodyStream;
Assert.IsTrue (stream.Length > 0);
Message m2 = TestUtils.CreateMessage (msg2);
m2.Formatter = new BinaryMessageFormatter ();
Assert.AreEqual(s, m2.Formatter.Read (m2), "The string did not serialise/deserialise properly");
mock1.Verify ();
mock2.Verify ();
}
[Test]
public void FormatComplexObject ()
{
Stream ms = new MemoryStream ();
mock1.ExpectAndReturn ("get_BodyStream", ms);
mock1.ExpectAndReturn ("get_BodyStream", ms);
mock2.ExpectAndReturn ("get_BodyStream", ms);
mock2.ExpectAndReturn ("get_BodyStream", ms);
Thingy2 t0 = new Thingy2();
t0.Iii = 42;
t0.Sss = "Some Text";
t0.Ttt = DateTime.Now;
Message m = TestUtils.CreateMessage (msg1);
m.Formatter = new BinaryMessageFormatter ();
m.Formatter.Write (m, t0);
Stream stream = m.BodyStream;
Assert.IsTrue (stream.Length > 0);
Message m2 = TestUtils.CreateMessage (msg2);
m2.Formatter = new BinaryMessageFormatter ();
Thingy2 t1 = (Thingy2) m2.Formatter.Read (m2);
Assert.AreEqual(t0.Iii, t1.Iii, "The string did not serialise/deserialise properly");
Assert.AreEqual(t0.Sss, t1.Sss, "The string did not serialise/deserialise properly");
Assert.AreEqual(t0.Ttt, t1.Ttt, "The string did not serialise/deserialise properly");
mock1.Verify ();
mock2.Verify ();
}
}
}

View File

@@ -1,109 +0,0 @@
//
// MessageEnumeratorTest.cs -
// NUnit Test Cases for MessageEnumerator
//
// Author:
// Michael Barker <mike@middlesoft.co.uk>
//
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Security;
using System.Security.Permissions;
using System.Reflection;
using Mono.Messaging;
using SystemMessageEnumerator = System.Messaging.MessageEnumerator;
using SystemMessageQueueException = System.Messaging.MessageQueueException;
using SystemIMessageFormatter = System.Messaging.IMessageFormatter;
using NUnit.Framework;
using NUnit.Mocks;
namespace MonoTests.Mono.Messaging {
[TestFixture]
public class MessageEnumeratorExceptionTest
{
private DynamicMock mockME;
[SetUp]
public void Init ()
{
mockME = new DynamicMock (typeof (IMessageEnumerator));
}
[Test]
[ExpectedException(typeof(SystemMessageQueueException))]
public void RemoveCurrentThrowsConnectionException ()
{
mockME.ExpectAndThrow ("RemoveCurrent", new ConnectionException (QueueReference.DEFAULT), null);
SystemMessageEnumerator me = CreateEnumerator ((IMessageEnumerator) mockME.MockInstance);
me.RemoveCurrent ();
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void RemoveCurrentThrowsMessageUnavailableException ()
{
mockME.ExpectAndThrow ("RemoveCurrent", new MessageUnavailableException (), null);
SystemMessageEnumerator me = CreateEnumerator ((IMessageEnumerator) mockME.MockInstance);
me.RemoveCurrent ();
}
[Test]
[ExpectedException(typeof(SystemMessageQueueException))]
public void RemoveCurrentThrowsMonoMessagingException ()
{
mockME.ExpectAndThrow ("RemoveCurrent", new MonoMessagingException (), null);
SystemMessageEnumerator me = CreateEnumerator ((IMessageEnumerator) mockME.MockInstance);
me.RemoveCurrent ();
}
[Test]
[ExpectedException(typeof(NotImplementedException))]
public void RemoveCurrentThrowsMessageNotImplemented ()
{
mockME.ExpectAndThrow ("RemoveCurrent", new NotImplementedException (), null);
SystemMessageEnumerator me = CreateEnumerator ((IMessageEnumerator) mockME.MockInstance);
me.RemoveCurrent ();
}
public SystemMessageEnumerator CreateEnumerator (IMessageEnumerator ime)
{
Type[] types = {
typeof (IMessageEnumerator), typeof (SystemIMessageFormatter)
};
ConstructorInfo ci = typeof (SystemMessageEnumerator).GetConstructor (
BindingFlags.NonPublic | BindingFlags.Instance,
Type.DefaultBinder, types, new ParameterModifier[0]);
if (ci == null)
throw new Exception ("ConstructorInfo is null");
return (SystemMessageEnumerator) ci.Invoke (new object[] { ime, null });
}
}
}

View File

@@ -1,68 +0,0 @@
//
// MessageTest.cs -
// NUnit Test Cases for MessageQueuePermissionAttribute
//
// Author:
// Michael Barker <sebastien@ximian.com>
//
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using NUnit.Mocks;
using System;
using System.Security;
using System.Security.Permissions;
using System.Reflection;
using SystemMessage = System.Messaging.Message;
using SystemAcknowledgeTypes = System.Messaging.AcknowledgeTypes;
using Mono.Messaging;
namespace MonoTests.Mono.Messaging.RabbitMQ {
[TestFixture]
public class MessageTest {
DynamicMock messageMock;
IMessage iMessage;
[SetUp]
public void SetUp ()
{
messageMock = new DynamicMock (typeof (IMessage));
iMessage = (IMessage) messageMock.MockInstance;
}
[Test]
public void SetProperties ()
{
messageMock.Expect ("set_AcknowledgeType",
AcknowledgeTypes.FullReachQueue);
SystemMessage m = TestUtils.CreateMessage (iMessage);
m.AcknowledgeType = SystemAcknowledgeTypes.FullReachQueue;
messageMock.Verify ();
}
}
}

View File

@@ -1,72 +0,0 @@
//
// MessageContextPoolTest.cs -
// NUnit Test Cases for MessageContextPool
//
// Author:
// Michael Barker <mike@middlesoft.co.uk>
//
// Copyright (C) 2008 Michael Barker
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Mono.Messaging;
using Mono.Messaging.RabbitMQ;
using RabbitMQ.Client;
using NUnit.Framework;
using NUnit.Mocks;
namespace MonoTests.Mono.Messaging.RabbitMQ {
[TestFixture]
public class MessagingContentPoolTest {
DynamicMock connectionMock;
IConnection connection;
MessageFactory messageFactory;
public void SetUp ()
{
connectionMock = new DynamicMock (typeof (IConnection));
connection = (IConnection) connectionMock.MockInstance;
messageFactory = new MessageFactory (new RabbitMQMessagingProvider ());
}
[Test]
public void ShouldAllocateReturnConnectionToPool ()
{
CreateConnectionDelegate handler = delegate (string host) {
return connection;
};
MessagingContextPool pool = new MessagingContextPool (messageFactory,
handler);
IMessagingContext context1 = pool.GetContext ("foo");
Assert.IsNotNull (context1);
context1.Dispose ();
IMessagingContext context2 = pool.GetContext ("foo");
Assert.AreEqual (context1, context2);
}
}
}

View File

@@ -1,153 +0,0 @@
//
// XmlMessageFormatterTest.cs -
// NUnit Test Cases for XmlMessageFormatterTest
//
// Author:
// Michael Barker <mike@middlesoft.co.uk>
//
// Copyright (C) 2008 Michael Barker
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using System.Messaging;
using Mono.Messaging;
using NUnit.Framework;
using NUnit.Mocks;
namespace MonoTests.Mono.Messaging.RabbitMQ
{
[TestFixture]
public class XmlMessageFormatterTest
{
DynamicMock mock1;
IMessage msg1;
DynamicMock mock2;
IMessage msg2;
[SetUp]
public void SetUp ()
{
mock1 = new DynamicMock (typeof (IMessage));
msg1 = (IMessage) mock1.MockInstance;
mock2 = new DynamicMock (typeof (IMessage));
msg2 = (IMessage) mock2.MockInstance;
}
[Test]
public void FormatString ()
{
Type[] t = { typeof (string) };
string s = "this is a test string";
Stream ms = new MemoryStream ();
mock1.ExpectAndReturn ("get_BodyStream", ms);
mock1.ExpectAndReturn ("get_BodyStream", ms);
mock2.ExpectAndReturn ("get_BodyStream", ms);
mock2.ExpectAndReturn ("get_BodyStream", ms);
Message m = TestUtils.CreateMessage (msg1);
XmlMessageFormatter xmlF = new XmlMessageFormatter ();
m.Formatter = xmlF;
m.Formatter.Write (m, s);
Stream stream = m.BodyStream;
Assert.AreEqual (typeof (string), xmlF.TargetTypes[0]);
Assert.IsTrue (stream.Length > 0);
Message m2 = TestUtils.CreateMessage (msg2);
m2.Formatter = new XmlMessageFormatter (t);
Assert.AreEqual (s, (string) m2.Formatter.Read (m2), "The string did not serialise/deserialise properly");
mock1.Verify ();
mock2.Verify ();
}
[Test]
public void FormatComplexObject ()
{
Type[] ts = { typeof (Thingy2) };
Stream ms = new MemoryStream ();
mock1.ExpectAndReturn ("get_BodyStream", ms);
mock1.ExpectAndReturn ("get_BodyStream", ms);
mock2.ExpectAndReturn ("get_BodyStream", ms);
mock2.ExpectAndReturn ("get_BodyStream", ms);
Thingy2 t0 = new Thingy2();
t0.Iii = 42;
t0.Sss = "Some Text";
t0.Ttt = DateTime.Now;
Message m = TestUtils.CreateMessage (msg1);
m.Formatter = new XmlMessageFormatter (ts);
m.Formatter.Write (m, t0);
Stream stream = m.BodyStream;
Assert.IsTrue (stream.Length > 0);
Message m2 = TestUtils.CreateMessage (msg2);
m2.Formatter = new XmlMessageFormatter (ts);
Thingy2 t1 = (Thingy2) m2.Formatter.Read (m2);
Assert.AreEqual (t0.Iii, t1.Iii, "The int did not serialise/deserialise properly");
Assert.AreEqual (t0.Sss, t1.Sss, "The string did not serialise/deserialise properly");
Assert.AreEqual (t0.Ttt.ToString (), t1.Ttt.ToString (), "The date did not serialise/deserialise properly");
mock1.Verify ();
mock2.Verify ();
}
}
[Serializable]
public class Thingy2
{
private int iii;
private string sss;
private DateTime ttt;
public int Iii {
get { return iii; }
set { iii = value; }
}
public string Sss {
get { return sss; }
set { sss = value; }
}
public DateTime Ttt {
get { return ttt; }
set { ttt = value; }
}
}
}