Skip to content

Commit

Permalink
test : GetValue
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed May 7, 2020
1 parent edd4c2c commit b2e6ad7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public async Task Blob()

Assert.NotNull(blob);
blob.GetResourceName().Should().Be("test");

(await blob.Name.GetValueAsync()).Should().Be("test");
}

[Fact]
Expand Down Expand Up @@ -162,6 +164,11 @@ public async Task Folder_WithFiles()
Assert.NotNull(blobs);

blobs.Count.Should().Be(4);

blobs[0].Name.GetValue().Should().Be("files.zip");
blobs[1].Name.GetValue().Should().Be("HtmlFile1.html");
blobs[2].Name.GetValue().Should().Be("TextFile1.txt");
blobs[3].Name.GetValue().Should().Be("x\\TextFile3.txt");
}

[Fact]
Expand Down
21 changes: 14 additions & 7 deletions tests/Pulumi.Azure.Extensions.Tests/TestingExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;

namespace Pulumi.Azure.Extensions.Tests
{
internal static class TestingExtensions
{
public static T GetValue<T>(this Output<T> output)
public static Task<T> GetValueAsync<T>(this Output<T> output)
{
var field = output.GetType().GetField("DataTask");
var tcs = new TaskCompletionSource<T>();
output.Apply(v =>
{
tcs.SetResult(v);
return v;
});

return tcs.Task;
}

return default;
public static T GetValue<T>(this Output<T> output)
{
return output.GetValueAsync().GetAwaiter().GetResult();
}
}
}

0 comments on commit b2e6ad7

Please sign in to comment.