From 9548f57c13c1b2956baebb01ce63983a83d81e3f Mon Sep 17 00:00:00 2001 From: Sergio Sisternes Date: Thu, 22 Jun 2017 22:41:42 +0200 Subject: [PATCH] Added basic XUnit project structure, sample code and information in the readme --- README.md | 12 ++++++++ tests/KubernetesClientConfigurationTests.cs | 32 +++++++++++++++++++++ tests/tests.csproj | 16 +++++++++++ 3 files changed, 60 insertions(+) create mode 100755 tests/KubernetesClientConfigurationTests.cs create mode 100755 tests/tests.csproj diff --git a/README.md b/README.md index 40404b27d..ea82fd288 100644 --- a/README.md +++ b/README.md @@ -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 +``` \ No newline at end of file diff --git a/tests/KubernetesClientConfigurationTests.cs b/tests/KubernetesClientConfigurationTests.cs new file mode 100755 index 000000000..d1d0c89af --- /dev/null +++ b/tests/KubernetesClientConfigurationTests.cs @@ -0,0 +1,32 @@ +using System; +using Xunit; +using k8s; + +namespace k8s.Tests +{ + public class KubernetesClientConfigurationTests + { + /// + /// Checks Host is loaded from the default configuration file + /// + [Fact] + public void DefaultConfigurationLoaded() + { + var cfg = new KubernetesClientConfiguration(); + Assert.NotNull(cfg.Host); + } + + /// + /// Checks if the are pods + /// + [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); + } + } +} diff --git a/tests/tests.csproj b/tests/tests.csproj new file mode 100755 index 000000000..c10375ec8 --- /dev/null +++ b/tests/tests.csproj @@ -0,0 +1,16 @@ + + + netcoreapp1.1 + false + + + + + + + + + + + + \ No newline at end of file