Skip to content

Commit 9548f57

Browse files
committed
Added basic XUnit project structure, sample code and information in the readme
1 parent 805cc31 commit 9548f57

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,15 @@ npm install autorest
2727
cd ${REPO_DIR}/csharp/src
2828
${GEN_DIR}/openapi/csharp.sh generated csharp.settings
2929
```
30+
31+
# Testing
32+
33+
The project uses [XUnit](https://xunit.github.io) as unit testing framework.
34+
35+
To run the tests you need to:
36+
37+
```bash
38+
cd tests
39+
dotnet restore
40+
dotnet xunit
41+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using Xunit;
3+
using k8s;
4+
5+
namespace k8s.Tests
6+
{
7+
public class KubernetesClientConfigurationTests
8+
{
9+
/// <summary>
10+
/// Checks Host is loaded from the default configuration file
11+
/// </summary>
12+
[Fact]
13+
public void DefaultConfigurationLoaded()
14+
{
15+
var cfg = new KubernetesClientConfiguration();
16+
Assert.NotNull(cfg.Host);
17+
}
18+
19+
/// <summary>
20+
/// Checks if the are pods
21+
/// </summary>
22+
[Fact]
23+
public void ListDefaultNamespacedPod()
24+
{
25+
var k8sClientConfig = new KubernetesClientConfiguration();
26+
IKubernetes client = new Kubernetes(k8sClientConfig);
27+
var listTask = client.ListNamespacedPodWithHttpMessagesAsync("default").Result;
28+
var list = listTask.Body;
29+
Assert.NotEqual(0, list.Items.Count);
30+
}
31+
}
32+
}

tests/tests.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netcoreapp1.1</TargetFramework>
4+
<IsPackable>false</IsPackable>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="xunit" Version="2.3.0-beta3-build3705" />
8+
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta3-build3705" />
9+
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="3.0.3" />
10+
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
11+
<PackageReference Include="YamlDotNet.NetCore" Version="1.0.0" />
12+
</ItemGroup>
13+
<ItemGroup>
14+
<ProjectReference Include="..\src\KubernetesClient.csproj" />
15+
</ItemGroup>
16+
</Project>

0 commit comments

Comments
 (0)