public void CallAsyncSequential() { var component = KtlInteropTestComponent.Create(); for (int i = 0; i < 400; ++i) { var task = component.OperationAsync(0, 0); Assert.IsTrue(task.Wait(10000)); } }
public void CallAsyncFailEnd() { var component = KtlInteropTestComponent.Create(); // try a bunch of different error codes FabricErrorCode[] errors = { FabricErrorCode.ReplicationQueueFull, FabricErrorCode.InvalidAtomicGroup, FabricErrorCode.InvalidNameUri }; foreach (var error in errors) { KtlAsyncInteropTest.CallAsyncVerifyError(component, end: error); } }
public void CallAsyncParallel() { var component = KtlInteropTestComponent.Create(); List <Task> tasks = new List <Task>(); for (int i = 0; i < 400; ++i) { var task = component.OperationAsync(0, 0); tasks.Add(task); } Assert.IsTrue(Task.WaitAll(tasks.ToArray(), 30000)); }
private static void CallAsyncVerifyError(KtlInteropTestComponent target, FabricErrorCode begin = FabricErrorCode.Unknown, FabricErrorCode end = FabricErrorCode.Unknown) { FabricException beginException = null; FabricException endException = null; Task task = null; try { task = target.OperationAsync((int)begin, (int)end); } catch (FabricException e) { beginException = e; } if (begin != FabricErrorCode.Unknown) { Assert.IsNotNull(beginException); Assert.AreEqual(beginException.ErrorCode, begin); return; } try { task.Wait(); } catch (AggregateException e) { endException = e.InnerException as FabricException; } if (end != FabricErrorCode.Unknown) { Assert.IsNotNull(endException); Assert.AreEqual(endException.ErrorCode, end); } }