forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebsiteStackTests.cs
73 lines (63 loc) · 1.94 KB
/
WebsiteStackTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright 2016-2020, Pulumi Corporation
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using NUnit.Framework;
using Pulumi;
using Pulumi.Testing;
using Pulumi.AzureNative.Resources;
using Pulumi.AzureNative.Storage;
namespace UnitTesting
{
/// <summary>
/// Unit testing examples.
/// </summary>
[TestFixture]
public class WebsiteStackTests
{
private static Task<ImmutableArray<Pulumi.Resource>> TestAsync()
{
return Pulumi.Deployment.TestAsync<WebsiteStack>(new Mocks(), new TestOptions {IsPreview = false});
}
[Test]
public async Task SingleResourceGroupExists()
{
var resources = await TestAsync();
var resourceGroups = resources.OfType<ResourceGroup>().ToList();
resourceGroups.Count.Should().Be(1, "a single resource group is expected");
}
[Test]
public async Task ResourceGroupHasEnvironmentTag()
{
var resources = await TestAsync();
var resourceGroup = resources.OfType<ResourceGroup>().First();
var tags = await resourceGroup.Tags.GetValueAsync();
tags.Should().NotBeNull("Tags must be defined");
tags.Should().ContainKey("Environment");
}
[Test]
public async Task StorageAccountExists()
{
var resources = await TestAsync();
var storageAccounts = resources.OfType<StorageAccount>();
var storageAccount = storageAccounts.SingleOrDefault();
storageAccount.Should().NotBeNull("Storage account not found");
}
[Test]
public async Task UploadsTwoFiles()
{
var resources = await TestAsync();
var files = resources.OfType<Blob>().ToList();
files.Count.Should().Be(2, "Should have uploaded files from `wwwroot`");
}
[Test]
public async Task StackExportsWebsiteUrl()
{
var resources = await TestAsync();
var stack = resources.OfType<WebsiteStack>().First();
var endpoint = await stack.Endpoint.GetValueAsync();
endpoint.Should().Be("https://wwwprodsa.web.core.windows.net");
}
}
}