Ensure that awaits do not continue on the captured context. (#370)
* Ensure that awaits do not continue on the captured context. * Make functions async for maintainability. * Add documentation detailing the use of UIFact.
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<PackageReference Include="Xunit.StaFact" Version="0.3.18" />
|
||||
<PackageReference Include="Moq" Version="4.13.1" />
|
||||
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using k8s.Exceptions;
|
||||
using k8s.KubeConfigModels;
|
||||
using Xunit;
|
||||
@@ -406,6 +407,17 @@ namespace k8s.Tests
|
||||
AssertConfigEqual(expectedCfg, cfg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures Kube config file can be loaded from within a non-default <see cref="SynchronizationContext"/>.
|
||||
/// The use of <see cref="UIFactAttribute"/> ensures the test is run from within a UI-like <see cref="SynchronizationContext"/>.
|
||||
/// </summary>
|
||||
[UIFact]
|
||||
public void BuildConfigFromConfigFileInfoOnNonDefaultSynchronizationContext()
|
||||
{
|
||||
var fi = new FileInfo("assets/kubeconfig.yml");
|
||||
KubernetesClientConfiguration.BuildConfigFromConfigFile(fi, "federal-context", useRelativePaths: false);
|
||||
}
|
||||
|
||||
private void AssertConfigEqual(K8SConfiguration expected, K8SConfiguration actual)
|
||||
{
|
||||
Assert.Equal(expected.ApiVersion, actual.ApiVersion);
|
||||
|
||||
Reference in New Issue
Block a user