Skip to content

Commit 76165cc

Browse files
committed
fix: Running tests
1 parent 1d765a6 commit 76165cc

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

Nickvision.Desktop.Tests/DatabaseKeyringServiceTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ public sealed class DatabaseKeyringServiceTests
1818
[TestMethod]
1919
public void Case001_Init()
2020
{
21+
#if OS_LINUX
2122
if (Environment.GetEnvironmentVariable("CI") == "true")
2223
{
2324
Assert.Inconclusive("Dialogs are not supported in CI environments");
2425
}
26+
#endif
2527
#pragma warning disable CA1416
2628
_keyringService = new DatabaseKeyringService(new AppInfo("org.nickvision.desktop.test", "Nickvision.Desktop.Test", "Test"), new SystemSecretService());
2729
#pragma warning restore CA1416
@@ -32,21 +34,25 @@ public void Case001_Init()
3234
[TestMethod]
3335
public void Case002_Check()
3436
{
37+
#if OS_LINUX
3538
if (Environment.GetEnvironmentVariable("CI") == "true")
3639
{
3740
Assert.Inconclusive("Dialogs are not supported in CI environments");
3841
}
42+
#endif
3943
Assert.IsNotNull(_keyringService);
4044
Assert.IsTrue(_keyringService.IsSavingToDisk);
4145
}
4246

4347
[TestMethod]
4448
public async Task Case003_Add()
4549
{
50+
#if OS_LINUX
4651
if (Environment.GetEnvironmentVariable("CI") == "true")
4752
{
4853
Assert.Inconclusive("Dialogs are not supported in CI environments");
4954
}
55+
#endif
5056
Assert.IsNotNull(_keyringService);
5157
Assert.IsTrue(await _keyringService.AddCredentialAsync(new Credential("YouTube", "abc", "123", new Uri("https://www.youtube.com"))));
5258
Assert.IsNotNull(_keyringService.Credentials.FirstOrDefault(c => c.Name == "YouTube"));
@@ -56,10 +62,12 @@ public async Task Case003_Add()
5662
[TestMethod]
5763
public async Task Case004_Update()
5864
{
65+
#if OS_LINUX
5966
if (Environment.GetEnvironmentVariable("CI") == "true")
6067
{
6168
Assert.Inconclusive("Dialogs are not supported in CI environments");
6269
}
70+
#endif
6371
Assert.IsNotNull(_keyringService);
6472
Assert.IsTrue(await _keyringService.AddCredentialAsync(new Credential("Google", "x@gmail.com", "asdfgh123!", new Uri("https://www.google.com"))));
6573
var cred = _keyringService.Credentials.FirstOrDefault(c => c.Name == "Google");
@@ -74,10 +82,12 @@ public async Task Case004_Update()
7482
[TestMethod]
7583
public async Task Case005_Remove()
7684
{
85+
#if OS_LINUX
7786
if (Environment.GetEnvironmentVariable("CI") == "true")
7887
{
7988
Assert.Inconclusive("Dialogs are not supported in CI environments");
8089
}
90+
#endif
8191
Assert.IsNotNull(_keyringService);
8292
Assert.IsTrue(await _keyringService.AddCredentialAsync(new Credential("Example", "user1", "pass1", new Uri("https://www.example.com"))));
8393
var cred = _keyringService.Credentials.FirstOrDefault(c => c.Name == "Example");
@@ -89,10 +99,12 @@ public async Task Case005_Remove()
8999
[TestMethod]
90100
public async Task Case006_Cleanup()
91101
{
102+
#if OS_LINUX
92103
if (Environment.GetEnvironmentVariable("CI") == "true")
93104
{
94105
Assert.Inconclusive("Dialogs are not supported in CI environments");
95106
}
107+
#endif
96108
Assert.IsNotNull(_keyringService);
97109
Assert.IsTrue(await _keyringService.DestroyAsync());
98110
Assert.IsFalse(_keyringService.Credentials.Any());

Nickvision.Desktop.Tests/Nickvision.Desktop.Tests.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
<Nullable>enable</Nullable>
99
</PropertyGroup>
1010

11+
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
12+
<DefineConstants>OS_WINDOWS</DefineConstants>
13+
</PropertyGroup>
14+
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
15+
<DefineConstants>OS_LINUX</DefineConstants>
16+
</PropertyGroup>
17+
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
18+
<DefineConstants>OS_MAC</DefineConstants>
19+
</PropertyGroup>
20+
1121
<ItemGroup>
1222
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
1323
<PackageReference Include="MSTest" Version="3.11.0"/>

Nickvision.Desktop.Tests/SystemSecretServiceTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,25 @@ public sealed class SystemSecretServiceTests
1616
[TestMethod]
1717
public void Case001_Initialize()
1818
{
19+
#if OS_LINUX
1920
if (Environment.GetEnvironmentVariable("CI") == "true")
2021
{
2122
Assert.Inconclusive("Dialogs are not supported in CI environments");
2223
}
24+
#endif
2325
_secretService = new SystemSecretService();
2426
Assert.IsNotNull(_secretService);
2527
}
2628

2729
[TestMethod]
2830
public async Task Case002_Add()
2931
{
32+
#if OS_LINUX
3033
if (Environment.GetEnvironmentVariable("CI") == "true")
3134
{
3235
Assert.Inconclusive("Dialogs are not supported in CI environments");
3336
}
37+
#endif
3438
Assert.IsNotNull(_secretService);
3539
var secret = new Secret("Nickvision.Desktop.Test", "abc");
3640
Assert.IsTrue(await _secretService.AddAsync(secret));
@@ -40,10 +44,12 @@ public async Task Case002_Add()
4044
[TestMethod]
4145
public async Task Case003_Create()
4246
{
47+
#if OS_LINUX
4348
if (Environment.GetEnvironmentVariable("CI") == "true")
4449
{
4550
Assert.Inconclusive("Dialogs are not supported in CI environments");
4651
}
52+
#endif
4753
Assert.IsNotNull(_secretService);
4854
var service = await _secretService.CreateAsync("Nickvision.Desktop.Test2");
4955
Assert.IsFalse(service is null);
@@ -53,10 +59,12 @@ public async Task Case003_Create()
5359
[TestMethod]
5460
public void Case004_Create()
5561
{
62+
#if OS_LINUX
5663
if (Environment.GetEnvironmentVariable("CI") == "true")
5764
{
5865
Assert.Inconclusive("Dialogs are not supported in CI environments");
5966
}
67+
#endif
6068
Assert.IsNotNull(_secretService);
6169
var service = _secretService.Create("Nickvision.Desktop.Test3");
6270
Assert.IsFalse(service is null);
@@ -66,10 +74,12 @@ public void Case004_Create()
6674
[TestMethod]
6775
public async Task Case005_Get()
6876
{
77+
#if OS_LINUX
6978
if (Environment.GetEnvironmentVariable("CI") == "true")
7079
{
7180
Assert.Inconclusive("Dialogs are not supported in CI environments");
7281
}
82+
#endif
7383
Assert.IsNotNull(_secretService);
7484
Assert.IsTrue(await _secretService.AddAsync(new Secret("Nickvision.Desktop.Test4", "abc")));
7585
var secret = _secretService.Get("Nickvision.Desktop.Test4");
@@ -81,10 +91,12 @@ public async Task Case005_Get()
8191
[TestMethod]
8292
public async Task Case006_Get()
8393
{
94+
#if OS_LINUX
8495
if (Environment.GetEnvironmentVariable("CI") == "true")
8596
{
8697
Assert.Inconclusive("Dialogs are not supported in CI environments");
8798
}
99+
#endif
88100
Assert.IsNotNull(_secretService);
89101
var secret = await _secretService.CreateAsync("Nickvision.Desktop.Test5");
90102
Assert.IsFalse(secret is null);
@@ -98,10 +110,12 @@ public async Task Case006_Get()
98110
[TestMethod]
99111
public async Task Case007_Update()
100112
{
113+
#if OS_LINUX
101114
if (Environment.GetEnvironmentVariable("CI") == "true")
102115
{
103116
Assert.Inconclusive("Dialogs are not supported in CI environments");
104117
}
118+
#endif
105119
Assert.IsNotNull(_secretService);
106120
Assert.IsTrue(_secretService.Add(new Secret("Nickvision.Desktop.Test6", "abc123")));
107121
var secret = await _secretService.GetAsync("Nickvision.Desktop.Test6");
@@ -118,10 +132,12 @@ public async Task Case007_Update()
118132
[TestMethod]
119133
public async Task Case008_Update()
120134
{
135+
#if OS_LINUX
121136
if (Environment.GetEnvironmentVariable("CI") == "true")
122137
{
123138
Assert.Inconclusive("Dialogs are not supported in CI environments");
124139
}
140+
#endif
125141
Assert.IsNotNull(_secretService);
126142
Assert.IsTrue(await _secretService.AddAsync(new Secret("Nickvision.Desktop.Test7", "abc123")));
127143
var secret = _secretService.Get("Nickvision.Desktop.Test7");
@@ -138,10 +154,12 @@ public async Task Case008_Update()
138154
[TestMethod]
139155
public async Task Case009_Delete()
140156
{
157+
#if OS_LINUX
141158
if (Environment.GetEnvironmentVariable("CI") == "true")
142159
{
143160
Assert.Inconclusive("Dialogs are not supported in CI environments");
144161
}
162+
#endif
145163
Assert.IsNotNull(_secretService);
146164
foreach (var cred in new[]
147165
{

0 commit comments

Comments
 (0)