Ejemplo n.º 1
0
        async Task TestAsyncMethodAPIs()
        {
            Log("");
            Log("Testing async methods...");

            currentTest = "TestAsync.StaticLogAsync(\"test\", fail: false)";
            await ExpectAsync(() => TestAsync.StaticLogAsync("test", fail: false));

            currentTest = "TestAsync.StaticEchoAsync(\"test\", fail: false)";
            await ExpectResultAsync("test", () => TestAsync.StaticEchoAsync("test", fail: false));

            currentTest = "TestAsync.StaticLogAsync(\"test\", fail: true)";
            await ExpectExceptionAsync(() => TestAsync.StaticLogAsync("test", fail: true));

            currentTest = "TestAsync.StaticEchoAsync(\"test\", fail: true)";
            await ExpectExceptionAsync(() => TestAsync.StaticEchoAsync("test", fail: true));

            var testAsyncInstance = new TestAsync();

            currentTest = "testAsyncInstance.LogAsync(\"test\", fail: false)";
            await ExpectAsync(() => testAsyncInstance.LogAsync("test", fail: false));

            currentTest = "testAsyncInstance.EchoAsync(\"test\", fail: false)";
            await ExpectResultAsync("test", () => testAsyncInstance.EchoAsync("test", fail: false));

            currentTest = "testAsyncInstance.LogAsync(\"test\", fail: true)";
            await ExpectExceptionAsync(() => testAsyncInstance.LogAsync("test", fail: true));

            currentTest = "testAsyncInstance.EchoAsync(\"test\", fail: true)";
            await ExpectExceptionAsync(() => testAsyncInstance.EchoAsync("test", fail: true));

            var testData = new TestStruct();

            testData.Value = new DateTimeOffset(new DateTime(2016, 6, 6));

            currentTest = "testAsyncInstance.EchoDataAsync({}, fail: false)";
            await ExpectResultAsync(() => testAsyncInstance.EchoDataAsync(testData, false),
                                    result => testData.Value == result?.Value);

            TestStruct[] testDataArray = new[] { new TestStruct(), new TestStruct() };
            testDataArray[0].Value = new DateTimeOffset(new DateTime(2016, 6, 7));
            testDataArray[1].Value = new DateTimeOffset(new DateTime(2016, 6, 8));

            currentTest = "testAsyncInstance.EchoDataListAsync([{},{}], fail: false)";
            await ExpectResultAsync(() => testAsyncInstance.EchoDataListAsync(testDataArray, false),
                                    result => 2 == result?.Count &&
                                    testDataArray[0].Value == result[0].Value &&
                                    testDataArray[1].Value == result[1].Value);
        }
Ejemplo n.º 2
0
 public static IAsyncOperation <TestStruct> StaticEchoDataAsync(TestStruct data, bool fail)
 {
     return(TestAsync.StaticEchoDataTaskAsync(data, fail).AsAsyncOperation());
 }
Ejemplo n.º 3
0
 public static IAsyncOperation <string> StaticEchoAsync(string text, bool fail)
 {
     return(TestAsync.StaticEchoTaskAsync(text, fail).AsAsyncOperation());
 }
Ejemplo n.º 4
0
 public static IAsyncAction StaticLogAsync(string text, bool fail)
 {
     return(TestAsync.StaticLogTaskAsync(text, fail).AsAsyncAction());
 }