From f21879c03b1963e243b7399fab5ae57256c96466 Mon Sep 17 00:00:00 2001 From: Zaid Ajaj Date: Wed, 17 Aug 2022 11:55:08 +0200 Subject: [PATCH] Add solution file and apply feedback from Fraser --- .../{infra => }/.gitignore | 0 .../PulumiUnitTesting.sln | 28 +++++++++++++++++++ testing-unit-cs-top-level-program/README.md | 12 ++------ 3 files changed, 31 insertions(+), 9 deletions(-) rename testing-unit-cs-top-level-program/{infra => }/.gitignore (100%) create mode 100644 testing-unit-cs-top-level-program/PulumiUnitTesting.sln diff --git a/testing-unit-cs-top-level-program/infra/.gitignore b/testing-unit-cs-top-level-program/.gitignore similarity index 100% rename from testing-unit-cs-top-level-program/infra/.gitignore rename to testing-unit-cs-top-level-program/.gitignore diff --git a/testing-unit-cs-top-level-program/PulumiUnitTesting.sln b/testing-unit-cs-top-level-program/PulumiUnitTesting.sln new file mode 100644 index 000000000..01228ebba --- /dev/null +++ b/testing-unit-cs-top-level-program/PulumiUnitTesting.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infra", "infra\Infra.csproj", "{75741B98-9641-4FCA-B4EE-23896787E3C2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "tests\Tests.csproj", "{0BBB322D-FEFF-493A-8BDC-13D5B0710C2D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {75741B98-9641-4FCA-B4EE-23896787E3C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75741B98-9641-4FCA-B4EE-23896787E3C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75741B98-9641-4FCA-B4EE-23896787E3C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75741B98-9641-4FCA-B4EE-23896787E3C2}.Release|Any CPU.Build.0 = Release|Any CPU + {0BBB322D-FEFF-493A-8BDC-13D5B0710C2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0BBB322D-FEFF-493A-8BDC-13D5B0710C2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0BBB322D-FEFF-493A-8BDC-13D5B0710C2D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0BBB322D-FEFF-493A-8BDC-13D5B0710C2D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/testing-unit-cs-top-level-program/README.md b/testing-unit-cs-top-level-program/README.md index 643e5b4e2..97be7c3b7 100644 --- a/testing-unit-cs-top-level-program/README.md +++ b/testing-unit-cs-top-level-program/README.md @@ -20,7 +20,7 @@ using Pulumi; return await Deployment.RunAsync(Deploy.Infra); -class Deploy +public class Deploy { public static Dictionary Infra() { @@ -31,23 +31,17 @@ class Deploy Here, the code that creates resources and returns outputs is inside the `Deploy.Infra` function which we can reference from the test project. > The return type of `Deploy.Infra` could also have been any of the following -> - `void` when we are not returning outputs +> - `void` when we are not returning any outputs > - `Task` when we want to `await` async code > - `Task>` when we want to `await` async code _and_ return outputs -There is a catch before we can reference `Deploy.Infra` from the unit tests. Since we don't have an explicit namespace here, we need to add this property to the project file -```xml - - - -``` Now we are ready to write unit tests. From a test project called `Tests`, add a reference to the project that contains the Pulumi program: ```xml ``` -Now, only for the tests we can create a _test stack_ that uses `Deploy.Infra` as follows +Now, just for the tests we can create a _test stack_ that uses `Deploy.Infra` as follows ```csharp class TestStack : Stack {