Added basic XUnit project structure, sample code and information in the readme

This commit is contained in:
Sergio Sisternes
2017-06-22 22:41:42 +02:00
parent 805cc31a9d
commit 9548f57c13
3 changed files with 60 additions and 0 deletions

View File

@@ -27,3 +27,15 @@ npm install autorest
cd ${REPO_DIR}/csharp/src
${GEN_DIR}/openapi/csharp.sh generated csharp.settings
```
# Testing
The project uses [XUnit](https://xunit.github.io) as unit testing framework.
To run the tests you need to:
```bash
cd tests
dotnet restore
dotnet xunit
```

View File

@@ -0,0 +1,32 @@
using System;
using Xunit;
using k8s;
namespace k8s.Tests
{
public class KubernetesClientConfigurationTests
{
/// <summary>
/// Checks Host is loaded from the default configuration file
/// </summary>
[Fact]
public void DefaultConfigurationLoaded()
{
var cfg = new KubernetesClientConfiguration();
Assert.NotNull(cfg.Host);
}
/// <summary>
/// Checks if the are pods
/// </summary>
[Fact]
public void ListDefaultNamespacedPod()
{
var k8sClientConfig = new KubernetesClientConfiguration();
IKubernetes client = new Kubernetes(k8sClientConfig);
var listTask = client.ListNamespacedPodWithHttpMessagesAsync("default").Result;
var list = listTask.Body;
Assert.NotEqual(0, list.Items.Count);
}
}
}

16
tests/tests.csproj Executable file
View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.3.0-beta3-build3705" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta3-build3705" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="3.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="YamlDotNet.NetCore" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\KubernetesClient.csproj" />
</ItemGroup>
</Project>