// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Threading.Tasks; namespace Microsoft.AspNet.Mvc.Core.Test { public class TestController { public static void VoidAction() { } #pragma warning disable 1998 public async Task TaskAction(int i, string s) { return; } #pragma warning restore 1998 #pragma warning disable 1998 public async Task TaskValueTypeAction(int i, string s) { return i; } #pragma warning restore 1998 #pragma warning disable 1998 public async Task> TaskOfTaskAction(int i, string s) { return TaskValueTypeAction(i, s); } #pragma warning restore 1998 public Task TaskValueTypeActionWithoutAsync(int i, string s) { return TaskValueTypeAction(i, s); } #pragma warning disable 1998 public async Task TaskActionWithException(int i, string s) { throw new NotImplementedException("Not Implemented Exception"); } #pragma warning restore 1998 public Task TaskActionWithExceptionWithoutAsync(int i, string s) { throw new NotImplementedException("Not Implemented Exception"); } public async Task TaskActionThrowAfterAwait(int i, string s) { await Task.Delay(500); throw new ArgumentException("Argument Exception"); } public TaskDerivedType TaskActionWithCustomTaskReturnType(int i, string s) { return new TaskDerivedType(); } public TaskOfTDerivedType TaskActionWithCustomTaskOfTReturnType(int i, string s) { return new TaskOfTDerivedType(1); } /// /// Returns a instead of a . This should throw an /// . /// public Task UnwrappedTask(int i, string s) { return Task.Factory.StartNew(async () => await Task.Delay(50)); } public string Echo(string input) { return input; } public string EchoWithException(string input) { throw new NotImplementedException(); } public dynamic ReturnTaskAsDynamicValue(int i, string s) { return Task.Factory.StartNew(() => i); } public class TaskDerivedType : Task { public TaskDerivedType() : base(() => Console.WriteLine("In The Constructor")) { } } public class TaskOfTDerivedType : Task { public TaskOfTDerivedType(T input) : base(() => input) { } } } }