コード例 #1
0
        public async Task TaskYields()
        {
            using (var context = AppDomainContext.Create())
            {
                await Task.Yield();

                var actual = await RemoteFuncAsync.InvokeAsync(
                    context.Domain,
                    10,
                    async (value) =>
                {
                    await Task.Yield();
                    var test = new Test()
                    {
                        Value1 = value
                    };
                    await Task.Yield();
                    return(test);
                });

                await Task.Yield();

                Assert.NotNull(actual);
                Assert.Equal(10, actual.Value1);
            }
        }
コード例 #2
0
        public async Task Serializable_FiveArg()
        {
            using (var context = AppDomainContext.Create())
            {
                var actual = await RemoteFuncAsync.InvokeAsync(
                    context.Domain,
                    10,
                    (short)11,
                    new Double?(12.0),
                    new Composite()
                {
                    Value = 13
                },
                    "Last",
                    async (value1, value2, value3, value4, value5) =>
                {
                    return(new Test()
                    {
                        Value1 = value1, Value2 = value2, Value3 = value3, Value4 = value4, Value5 = value5
                    });
                });

                Assert.NotNull(actual);
                Assert.Equal(10, actual.Value1);
                Assert.Equal(11, actual.Value2);
                Assert.Equal(12, actual.Value3);
                Assert.NotNull(actual.Value4);
                Assert.Equal("Last", actual.Value5);
                Assert.Equal(13, actual.Value4.Value);
            }
        }
コード例 #3
0
 public void InstanceFourTypes_NullFunction()
 {
     Assert.Throws(typeof(ArgumentNullException), () =>
     {
         var action = new RemoteFuncAsync <int, int, int, int>();
         action.Invoke(1, 2, 3, null, null);
     });
 }
コード例 #4
0
 public void InstanceFourTypes_NullFunction()
 {
     Assert.Throws(typeof(ArgumentNullException), () =>
     {
         var action = new RemoteFuncAsync<int, int, int, int>();
         action.Invoke(1, 2, 3, null, null);
     });
 }
コード例 #5
0
        public async Task EmptyFunction()
        {
            using (var context = AppDomainContext.Create())
            {
                var actual = await RemoteFuncAsync.InvokeAsync(context.Domain, async() => { return(1); });

                Assert.Equal(1, actual);
            }
        }
コード例 #6
0
 public async Task NullFunction()
 {
     await Assert.ThrowsAsync(typeof(ArgumentNullException), async() =>
     {
         using (var context = AppDomainContext.Create())
         {
             var actual = await RemoteFuncAsync.InvokeAsync <int>(context.Domain, null);
         }
     });
 }
コード例 #7
0
 public async Task NullDomain()
 {
     await Assert.ThrowsAsync(typeof(ArgumentNullException), async() =>
     {
         await RemoteFuncAsync.InvokeAsync(null, async() =>
         {
             return(1);
         });
     });
 }
コード例 #8
0
 public async Task Save_TraceEvent()
 {
     await SaveTraceEvent(afterSaveTrace : async() => {
         var appDomainContext2 = AppDomainContext.Create(AppDomain.CurrentDomain.SetupInformation);
         await RemoteFuncAsync.InvokeAsync(appDomainContext2.Domain, async() => {
             await SaveTraceEvent();
             return(Unit.Default);
         });
         appDomainContext2.Dispose();
     });
 }
コード例 #9
0
 public void InstanceFiveTypes_NullFunction()
 {
     Assert.Throws(typeof(ArgumentNullException), () =>
     {
         try
         {
             var action = new RemoteFuncAsync <int, int, int, int, int>();
             action.Invoke(1, 2, 3, 4, null, null);
         }
         catch (Exception)
         {
             throw;
         }
     });
 }
コード例 #10
0
        public async Task Serializable_NoArguments()
        {
            using (var context = AppDomainContext.Create())
            {
                var actual = await RemoteFuncAsync.InvokeAsync(
                    context.Domain,
                    async() =>
                {
                    return(new Test()
                    {
                        Value1 = 10
                    });
                });

                Assert.NotNull(actual);
                Assert.Equal(10, actual.Value1);
            }
        }
コード例 #11
0
        public async Task Delay_Long()
        {
            using (var context = AppDomainContext.Create())
            {
                var actual = await RemoteFuncAsync.InvokeAsync(
                    context.Domain,
                    10,
                    async (value) =>
                {
                    await Task.Delay(1000);
                    return(new Test()
                    {
                        Value1 = value
                    });
                });

                Assert.NotNull(actual);
                Assert.Equal(10, actual.Value1);
            }
        }
コード例 #12
0
        public async Task Exception()
        {
            await Assert.ThrowsAsync(typeof(AggregateException), async() =>
            {
                using (var context = AppDomainContext.Create())
                {
                    Test actual = null;

                    CancellationTokenSource tcs = new CancellationTokenSource();
                    actual = await RemoteFuncAsync.InvokeAsync(
                        context.Domain,
                        10,
                        (short)11,
                        new Double?(12.0),
                        new Composite()
                    {
                        Value = 13
                    },
                        "Last",
                        async(value1, value2, value3, value4, value5) =>
                    {
                        if (value5 == "Last")
                        {
                            throw new Exception("");
                        }
                        return(new Test()
                        {
                            Value1 = value1, Value2 = value2, Value3 = value3, Value4 = value4, Value5 = value5
                        });
                    });

                    Assert.NotNull(actual);
                    Assert.Equal(10, actual.Value1);
                    Assert.Equal(11, actual.Value2);
                    Assert.Equal(12, actual.Value3);
                    Assert.NotNull(actual.Value4);
                    Assert.Equal("Last", actual.Value5);
                    Assert.Equal(13, actual.Value4.Value);
                }
            });
        }
コード例 #13
0
        public async Task Serializable_TwoArg()
        {
            using (var context = AppDomainContext.Create())
            {
                var actual = await RemoteFuncAsync.InvokeAsync(
                    context.Domain,
                    10,
                    (short)11,
                    async (value1, value2) =>
                {
                    return(new Test()
                    {
                        Value1 = value1, Value2 = value2
                    });
                });

                Assert.NotNull(actual);
                Assert.Equal(10, actual.Value1);
                Assert.Equal(11, actual.Value2);
            }
        }
コード例 #14
0
 public void InstanceFiveTypes_NullFunction()
 {
     Assert.Throws(typeof(ArgumentNullException), () =>
     {
         try
         {
             var action = new RemoteFuncAsync<int, int, int, int, int>();
             action.Invoke(1, 2, 3, 4, null, null);
         }
         catch (Exception)
         {
             throw;
         }
     });
 }