Skip to content

Commit 800c4b2

Browse files
committed
feat: Cleanup
1 parent 4dbeadf commit 800c4b2

29 files changed

+232
-342
lines changed

Nickvision.Desktop.Tests/DatabaseKeyringServiceTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.IO;
77
using System.Linq;
88
using System.Threading.Tasks;
9-
using Environment = System.Environment;
109

1110
namespace Nickvision.Desktop.Tests;
1211

Nickvision.Desktop.Tests/EnvironmentTests.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,10 @@ namespace Nickvision.Desktop.Tests;
88
public sealed class EnvironmentTests
99
{
1010
[TestMethod]
11-
public void Case001_Deployment()
12-
{
13-
Assert.AreEqual(DeploymentMode.Local, Environment.DeploymentMode);
14-
}
11+
public void Case001_Deployment() => Assert.AreEqual(DeploymentMode.Local, Environment.DeploymentMode);
1512

1613
[TestMethod]
17-
public void Case002_PathVariable()
18-
{
19-
Assert.IsTrue(Environment.PathVariable.Any());
20-
}
14+
public void Case002_PathVariable() => Assert.IsTrue(Environment.PathVariable.Any());
2115

2216
[TestMethod]
2317
public void Case003_GlobalDependency()

Nickvision.Desktop.Tests/GitHubUpdaterServiceTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ public static void ClassInitialize(TestContext context)
2929
}
3030

3131
[ClassCleanup]
32-
public static void ClassCleanup()
33-
{
34-
_client?.Dispose();
35-
}
32+
public static void ClassCleanup() => _client?.Dispose();
3633

3734
[TestMethod]
3835
public void Case001_Initialize()

Nickvision.Desktop.Tests/JsonFileServiceTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ namespace Nickvision.Desktop.Tests;
77

88
public class Config
99
{
10+
public bool DarkModeEnabled { get; set; }
11+
public WindowGeometry WindowGeometry { get; set; }
12+
1013
public Config()
1114
{
1215
DarkModeEnabled = false;
1316
WindowGeometry = new WindowGeometry();
1417
}
15-
16-
public bool DarkModeEnabled { get; set; }
17-
public WindowGeometry WindowGeometry { get; set; }
1818
}
1919

2020
[TestClass]

Nickvision.Desktop.Tests/ServiceCollectionTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public TestService()
1717
Disposed = false;
1818
}
1919

20+
~TestService()
21+
{
22+
Dispose(false);
23+
}
24+
2025
public bool Disposed { get; private set; }
2126

2227
public void Dispose()
@@ -27,11 +32,6 @@ public void Dispose()
2732

2833
public string GetData() => "Test Data";
2934

30-
~TestService()
31-
{
32-
Dispose(false);
33-
}
34-
3535
private void Dispose(bool disposing)
3636
{
3737
if (Disposed || !disposing)

Nickvision.Desktop.Tests/SystemSecretServiceTests.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Nickvision.Desktop.System;
22
using System.Runtime.Versioning;
33
using System.Threading.Tasks;
4-
using Environment = System.Environment;
54

65
namespace Nickvision.Desktop.Tests;
76

@@ -162,15 +161,15 @@ public async Task Case009_Delete()
162161
#endif
163162
Assert.IsNotNull(_secretService);
164163
foreach (var cred in new[]
165-
{
166-
"Nickvision.Desktop.Test",
167-
"Nickvision.Desktop.Test2",
168-
"Nickvision.Desktop.Test3",
169-
"Nickvision.Desktop.Test4",
170-
"Nickvision.Desktop.Test5",
171-
"Nickvision.Desktop.Test6",
172-
"Nickvision.Desktop.Test7"
173-
})
164+
{
165+
"Nickvision.Desktop.Test",
166+
"Nickvision.Desktop.Test2",
167+
"Nickvision.Desktop.Test3",
168+
"Nickvision.Desktop.Test4",
169+
"Nickvision.Desktop.Test5",
170+
"Nickvision.Desktop.Test6",
171+
"Nickvision.Desktop.Test7"
172+
})
174173
{
175174
Assert.IsTrue(await _secretService.DeleteAsync(cred));
176175
}

Nickvision.Desktop.Tests/UserDirectoriesTests.cs

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,35 @@ namespace Nickvision.Desktop.Tests;
77
public sealed class UserDirectoriesTests
88
{
99
[TestMethod]
10-
public void Case001_HomeDirectoryExists()
11-
{
12-
Assert.IsTrue(Directory.Exists(UserDirectories.Home));
13-
}
10+
public void Case001_HomeDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Home));
1411

1512
[TestMethod]
16-
public void Case002_ConfigDirectoryExists()
17-
{
18-
Assert.IsTrue(Directory.Exists(UserDirectories.Config));
19-
}
13+
public void Case002_ConfigDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Config));
2014

2115
[TestMethod]
22-
public void Case003_CacheDirectoryExists()
23-
{
24-
Assert.IsTrue(Directory.Exists(UserDirectories.Cache));
25-
}
16+
public void Case003_CacheDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Cache));
2617

2718
[TestMethod]
28-
public void Case005_LocalDataDirectoryExists()
29-
{
30-
Assert.IsTrue(Directory.Exists(UserDirectories.LocalData));
31-
}
19+
public void Case005_LocalDataDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.LocalData));
3220

3321
[TestMethod]
34-
public void Case006_DesktopDirectoryExists()
35-
{
36-
Assert.IsTrue(Directory.Exists(UserDirectories.Desktop));
37-
}
22+
public void Case006_DesktopDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Desktop));
3823

3924
[TestMethod]
40-
public void Case007_DocumentsDirectoryExists()
41-
{
42-
Assert.IsTrue(Directory.Exists(UserDirectories.Documents));
43-
}
25+
public void Case007_DocumentsDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Documents));
4426

4527
[TestMethod]
46-
public void Case008_DownloadsDirectoryExists()
47-
{
48-
Assert.IsTrue(Directory.Exists(UserDirectories.Downloads));
49-
}
28+
public void Case008_DownloadsDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Downloads));
5029

5130
[TestMethod]
52-
public void Case009_MusicDirectoryExists()
53-
{
54-
Assert.IsTrue(Directory.Exists(UserDirectories.Music));
55-
}
31+
public void Case009_MusicDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Music));
5632

5733
[TestMethod]
58-
public void Case010_PicturesDirectoryExists()
59-
{
60-
Assert.IsTrue(Directory.Exists(UserDirectories.Pictures));
61-
}
34+
public void Case010_PicturesDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Pictures));
6235

6336
[TestMethod]
64-
public void Case011_TemplatesDirectoryExists()
65-
{
66-
Assert.IsTrue(Directory.Exists(UserDirectories.Templates));
67-
}
37+
public void Case011_TemplatesDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Templates));
6838

6939
[TestMethod]
70-
public void Case012_VideosDirectoryExists()
71-
{
72-
Assert.IsTrue(Directory.Exists(UserDirectories.Videos));
73-
}
40+
public void Case012_VideosDirectoryExists() => Assert.IsTrue(Directory.Exists(UserDirectories.Videos));
7441
}

Nickvision.Desktop/Application/AppInfo.cs

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,101 +10,101 @@ namespace Nickvision.Desktop.Application;
1010
public class AppInfo
1111
{
1212
/// <summary>
13-
/// Constructs an AppInfo.
13+
/// A map of artists' names and their emails related to the app.
1414
/// </summary>
15-
/// <param name="id">The id of the app</param>
16-
/// <param name="name">The name of the app</param>
17-
/// <param name="englishShortName">The short name of the app in English (untranslated)</param>
18-
public AppInfo(string id, string name, string englishShortName)
19-
{
20-
Id = id;
21-
Name = name;
22-
EnglishShortName = englishShortName;
23-
ExtraLinks = [];
24-
Developers = [];
25-
Designers = [];
26-
Artists = [];
27-
}
15+
public Dictionary<string, string> Artists { get; }
2816

2917
/// <summary>
30-
/// The id of the app.
18+
/// The changelog of the app in Markdown format.
3119
/// </summary>
32-
public string Id { get; init; }
20+
public string? Changelog { get; set; }
3321

3422
/// <summary>
35-
/// The name of the app.
23+
/// The description of the app.
3624
/// </summary>
37-
public string Name { get; init; }
25+
public string? Description { get; set; }
3826

3927
/// <summary>
40-
/// The short name of the app in English (untranslated).
28+
/// A map of designers' names and their emails related to the app.
4129
/// </summary>
42-
public string EnglishShortName { get; init; }
30+
public Dictionary<string, string> Designers { get; }
4331

4432
/// <summary>
45-
/// The short name of the app (translated).
33+
/// A map of developers' names and their emails related to the app.
4634
/// </summary>
47-
public string? ShortName { get; set; }
35+
public Dictionary<string, string> Developers { get; }
4836

4937
/// <summary>
50-
/// The description of the app.
38+
/// The url to the discussions forum of the app.
5139
/// </summary>
52-
public string? Description { get; set; }
40+
public Uri? DiscussionsForum { get; set; }
5341

5442
/// <summary>
55-
/// The current running version of the app.
43+
/// The url to the documentation store of the app.
5644
/// </summary>
57-
public AppVersion? Version { get; set; }
45+
public Uri? DocumentationStore { get; set; }
5846

5947
/// <summary>
60-
/// The changelog of the app in Markdown format.
48+
/// The short name of the app in English (untranslated).
6149
/// </summary>
62-
public string? Changelog { get; set; }
50+
public string EnglishShortName { get; init; }
6351

6452
/// <summary>
65-
/// The url to the source repository of the app.
53+
/// A map of extra links' names and their urls related to the app.
6654
/// </summary>
67-
public Uri? SourceRepository { get; set; }
55+
public Dictionary<string, Uri> ExtraLinks { get; }
6856

6957
/// <summary>
70-
/// The url to the issue tracker of the app.
58+
/// The id of the app.
7159
/// </summary>
72-
public Uri? IssueTracker { get; set; }
60+
public string Id { get; init; }
7361

7462
/// <summary>
75-
/// The url to the discussions forum of the app.
63+
/// The url to the issue tracker of the app.
7664
/// </summary>
77-
public Uri? DiscussionsForum { get; set; }
65+
public Uri? IssueTracker { get; set; }
7866

7967
/// <summary>
80-
/// The url to the documentation store of the app.
68+
/// The name of the app.
8169
/// </summary>
82-
public Uri? DocumentationStore { get; set; }
70+
public string Name { get; init; }
8371

8472
/// <summary>
85-
/// A map of extra links' names and their urls related to the app.
73+
/// The short name of the app (translated).
8674
/// </summary>
87-
public Dictionary<string, Uri> ExtraLinks { get; }
75+
public string? ShortName { get; set; }
8876

8977
/// <summary>
90-
/// A map of developers' names and their emails related to the app.
78+
/// The url to the source repository of the app.
9179
/// </summary>
92-
public Dictionary<string, string> Developers { get; }
80+
public Uri? SourceRepository { get; set; }
9381

9482
/// <summary>
95-
/// A map of designers' names and their emails related to the app.
83+
/// The translation credits for the app.
9684
/// </summary>
97-
public Dictionary<string, string> Designers { get; }
85+
public string? TranslationCredits { get; set; }
9886

9987
/// <summary>
100-
/// A map of artists' names and their emails related to the app.
88+
/// The current running version of the app.
10189
/// </summary>
102-
public Dictionary<string, string> Artists { get; }
90+
public AppVersion? Version { get; set; }
10391

10492
/// <summary>
105-
/// The translation credits for the app.
93+
/// Constructs an AppInfo.
10694
/// </summary>
107-
public string? TranslationCredits { get; set; }
95+
/// <param name="id">The id of the app</param>
96+
/// <param name="name">The name of the app</param>
97+
/// <param name="englishShortName">The short name of the app in English (untranslated)</param>
98+
public AppInfo(string id, string name, string englishShortName)
99+
{
100+
Id = id;
101+
Name = name;
102+
EnglishShortName = englishShortName;
103+
ExtraLinks = [];
104+
Developers = [];
105+
Designers = [];
106+
Artists = [];
107+
}
108108

109109
/// <summary>
110110
/// The changelog of the app in HTML format.

Nickvision.Desktop/Application/AppVersion.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ namespace Nickvision.Desktop.Application;
44

55
public class AppVersion
66
{
7+
public Version BaseVersion { get; init; }
8+
public string PreviewLabel { get; init; }
9+
710
public AppVersion(string version)
811
{
912
var dashIndex = version.IndexOf('-');
@@ -22,9 +25,6 @@ public AppVersion(Version version)
2225
PreviewLabel = string.Empty;
2326
}
2427

25-
public Version BaseVersion { get; init; }
26-
public string PreviewLabel { get; init; }
27-
2828
public bool IsPreview => !string.IsNullOrEmpty(PreviewLabel);
2929

3030
public static bool TryParse(string version, out AppVersion? appVersion)
@@ -83,15 +83,13 @@ public static bool TryParse(string version, out AppVersion? appVersion)
8383

8484
public static bool operator !=(AppVersion? pv, Version? v) => !(pv == v);
8585

86-
public override bool Equals(object? obj)
87-
{
88-
return obj switch
86+
public override bool Equals(object? obj) =>
87+
obj switch
8988
{
9089
AppVersion pv => this == pv,
9190
Version v => this == v,
9291
var _ => false
9392
};
94-
}
9593

9694
public override int GetHashCode() => ToString().GetHashCode();
9795

0 commit comments

Comments
 (0)