|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Threading.Tasks; |
| 4 | +using Microsoft.Rest; |
| 5 | +using Xunit; |
| 6 | +using Microsoft.WindowsAzure.Commands.ScenarioTest; |
| 7 | + |
| 8 | +namespace Microsoft.Azure.Commands.Common.Strategies.UnitTest |
| 9 | +{ |
| 10 | + public class AsyncCmdletExtensionsTest |
| 11 | + { |
| 12 | + class Client : IClient |
| 13 | + { |
| 14 | + public T GetClient<T>() where T : ServiceClient<T> |
| 15 | + => null; |
| 16 | + } |
| 17 | + |
| 18 | + class RG { } |
| 19 | + |
| 20 | + class Parameters : IParameters<RG> |
| 21 | + { |
| 22 | + public string Location |
| 23 | + { |
| 24 | + get |
| 25 | + { |
| 26 | + return "somelocation"; |
| 27 | + } |
| 28 | + |
| 29 | + set |
| 30 | + { |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + public async Task<ResourceConfig<RG>> CreateConfigAsync() |
| 35 | + => new ResourceConfig<RG>( |
| 36 | + new ResourceStrategy<RG>( |
| 37 | + null, |
| 38 | + async (c, p) => new RG(), |
| 39 | + null, |
| 40 | + null, |
| 41 | + null, |
| 42 | + false), |
| 43 | + null, |
| 44 | + null, |
| 45 | + null, |
| 46 | + null); |
| 47 | + } |
| 48 | + |
| 49 | + class AsyncCmdlet : IAsyncCmdlet |
| 50 | + { |
| 51 | + public IEnumerable<KeyValuePair<string, object>> Parameters |
| 52 | + { |
| 53 | + get |
| 54 | + { |
| 55 | + yield return new KeyValuePair<string, object>("Str", "str"); |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + public string VerbsNew |
| 60 | + { |
| 61 | + get |
| 62 | + { |
| 63 | + throw new NotImplementedException(); |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + public void ReportTaskProgress(ITaskProgress taskProgress) |
| 68 | + { |
| 69 | + throw new NotImplementedException(); |
| 70 | + } |
| 71 | + |
| 72 | + public Task<bool> ShouldProcessAsync(string target, string action) |
| 73 | + { |
| 74 | + throw new NotImplementedException(); |
| 75 | + } |
| 76 | + |
| 77 | + public void WriteObject(object value) |
| 78 | + { |
| 79 | + throw new NotImplementedException(); |
| 80 | + } |
| 81 | + |
| 82 | + public void WriteVerbose(string message) |
| 83 | + { |
| 84 | + Assert.Equal("Str = \"str\"", message); |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + [Fact] |
| 89 | + [Trait(Category.AcceptanceType, Category.CheckIn)] |
| 90 | + public async Task TestVerboseStream() |
| 91 | + { |
| 92 | + var client = new Client(); |
| 93 | + var parameters = new Parameters(); |
| 94 | + var asyncCmdlet = new AsyncCmdlet(); |
| 95 | + |
| 96 | + await client.RunAsync("subscriptionId", parameters, asyncCmdlet, new System.Threading.CancellationToken()); |
| 97 | + } |
| 98 | + } |
| 99 | +} |
0 commit comments