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); } }
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); } }
public void InstanceFourTypes_NullFunction() { Assert.Throws(typeof(ArgumentNullException), () => { var action = new RemoteFuncAsync <int, int, int, int>(); action.Invoke(1, 2, 3, null, null); }); }
public void InstanceFourTypes_NullFunction() { Assert.Throws(typeof(ArgumentNullException), () => { var action = new RemoteFuncAsync<int, int, int, int>(); action.Invoke(1, 2, 3, null, null); }); }
public async Task EmptyFunction() { using (var context = AppDomainContext.Create()) { var actual = await RemoteFuncAsync.InvokeAsync(context.Domain, async() => { return(1); }); Assert.Equal(1, actual); } }
public async Task NullFunction() { await Assert.ThrowsAsync(typeof(ArgumentNullException), async() => { using (var context = AppDomainContext.Create()) { var actual = await RemoteFuncAsync.InvokeAsync <int>(context.Domain, null); } }); }
public async Task NullDomain() { await Assert.ThrowsAsync(typeof(ArgumentNullException), async() => { await RemoteFuncAsync.InvokeAsync(null, async() => { return(1); }); }); }
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(); }); }
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; } }); }
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); } }
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); } }
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); } }); }
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); } }
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; } }); }