How to use this appendix
Use this when you need the complete canonical C# demo listing rather than the smaller excerpts shown in the chapters.
A.1 Repository tree
jenkins-csharp-demo/
├── src/
│ └── JenkinsHelloWorld/
│ ├── Greeting.cs
│ ├── JenkinsHelloWorld.csproj
│ └── Program.cs
├── tests/
│ └── JenkinsHelloWorld.Tests/
│ ├── GreetingTests.cs
│ └── JenkinsHelloWorld.Tests.csproj
├── JenkinsCSharpDemo.sln
├── Jenkinsfile
├── azure-pipelines.yml
└── .github/
└── workflows/
└── csharp-ci.yml
A.2 Greeting.cs
namespace JenkinsHelloWorld;
public static class Greeting
{
// Return the message from a method rather than hard-coding it
// directly in Program.cs. This gives the unit test something
// small and deterministic to verify.
public static string GetMessage()
{
return "Hello, world!";
}
}
A.3 Program.cs
using JenkinsHelloWorld;
// Keep the executable intentionally tiny.
// CI/CD is the focus of this guide, not application complexity.
Console.WriteLine(Greeting.GetMessage());
A.4 GreetingTests.cs
using JenkinsHelloWorld;
namespace JenkinsHelloWorld.Tests;
public class GreetingTests
{
[Fact]
public void GetMessage_ReturnsExpectedGreeting()
{
// Arrange: define the behavior we expect.
const string expected = "Hello, world!";
// Act: call the production code.
string actual = Greeting.GetMessage();
// Assert: fail the test if behavior changed unexpectedly.
Assert.Equal(expected, actual);
}
}