diff --git a/Examples/ExampleApps.cs b/Examples/ExampleApps.cs index 998fcb4..e234629 100644 --- a/Examples/ExampleApps.cs +++ b/Examples/ExampleApps.cs @@ -238,8 +238,13 @@ public static ExampleAppOptions BuildOptions( StartupTimeoutSeconds: 180, BuildEnv: o => new Dictionary { + // The example reads the _51DEGREES_ names. Released + // versions of it read the two older names, so both + // are set until every language has released. + ["_51DEGREES_RESOURCE_KEY"] = o.ResourceKey, ["SUPER_RESOURCE_KEY"] = o.ResourceKey, // the endpoint must include the api/v4 path + ["_51DEGREES_CLOUD_ENDPOINT"] = new Uri(o.CloudEndpoint, "api/v4/").ToString(), ["FIFTYONE_CLOUD_ENDPOINT"] = new Uri(o.CloudEndpoint, "api/v4/").ToString(), ["ASPNETCORE_URLS"] = $"http://localhost:{o.Port}", // run on a newer .NET runtime if the exact one isn't installed diff --git a/Examples/ExampleAppsTests.cs b/Examples/ExampleAppsTests.cs index 3f271e6..0e5ce16 100644 --- a/Examples/ExampleAppsTests.cs +++ b/Examples/ExampleAppsTests.cs @@ -1,3 +1,5 @@ +using System; +using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -74,5 +76,23 @@ public void Descriptors_Rust_BuildsAndRunsWithCargo() Assert.IsTrue(rust.Args.Contains("dd-web-getting-started-cloud"), "run args should target the cloud getting-started web binary"); } + + [TestMethod] + public void Descriptors_Dotnet_SetsTheUnderscoreNames() + { + var dotnet = ExampleApps.Descriptors["dotnet"]; + var env = dotnet.BuildEnv(new ExampleAppOptions( + Port: 5123, + CloudEndpoint: new Uri("https://cloud.example.test/"), + ResourceKey: "key", + ExtraEnv: new Dictionary())); + Assert.AreEqual("key", env["_51DEGREES_RESOURCE_KEY"], + "the example reads the resource key from this name"); + Assert.AreEqual( + "https://cloud.example.test/api/v4/", + env["_51DEGREES_CLOUD_ENDPOINT"], + "the example reads the endpoint, with its api/v4 path, " + + "from this name"); + } } }