Fix copyright
[mono-project.git] / mcs / class / corlib / Test / System.Runtime.Remoting / RemotingServicesTest.cs
blob8f01385fab3e41ea50069e1acdfe076b91297e65
1 //
2 // MonoTests.System.Runtime.Remoting.RemotingServicesTest.cs
3 //
4 // Author: Alexis Christoforides (alchri@microsoft.com)
5 //
6 // Copyright (c) Microsoft. All rights reserved.
7 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
9 using System;
10 using System.Reflection;
11 using System.Threading.Tasks;
12 using NUnit.Framework;
14 namespace MonoTests.System.Runtime.Remoting
16 [TestFixture]
17 public class RemotingServicesTest
19 public class AppDomainObject : MarshalByRefObject
21 public void Init(CrossDomainSerializedObject applicationDependencies) // racy exception here
27 public class CrossDomainSerializedObject : MarshalByRefObject
30 private static CrossDomainSerializedObject crossDomainSerializedObject;
32 private static void AppDomainWithRemotingSerialization(Assembly assembly, string name)
34 var appDomain = AppDomain.CreateDomain(name);
35 var appDomainObject = (AppDomainObject)appDomain.CreateInstanceAndUnwrap(assembly.GetName().Name, typeof(AppDomainObject).FullName);
36 appDomainObject.Init(crossDomainSerializedObject);
39 [Test]
40 public void Bug46473 () // concurrent serialization/deserialization
42 bool success = true;
43 crossDomainSerializedObject = new CrossDomainSerializedObject();
44 Task[] tasks = new Task [20];
45 for (int i = 0; i < tasks.Length; i++)
47 var assembly = Assembly.GetAssembly(typeof(AppDomainObject));
48 var name = "AppDomainWithCall" + i;
49 tasks [i] = Task.Factory.StartNew(() => AppDomainWithRemotingSerialization(assembly, name));
51 try {
52 Task.WaitAll (tasks);
53 } catch (AggregateException e) {
54 success = false;
55 Console.WriteLine ($"{e}, {e.InnerException}");
57 Assert.IsTrue (success, "Bug46473 (exception during remoting call)");