Skip to content

Added basic XUnit project structure #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
32 changes: 32 additions & 0 deletions tests/KubernetesClientConfigurationTests.cs
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions tests/tests.csproj
Original file line number Diff line number Diff line change
@@ -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>