Skip to content

Commit 8add42d

Browse files
author
BRUNER Patrick
committed
unittests
1 parent 1c2e911 commit 8add42d

18 files changed

Lines changed: 2981 additions & 50 deletions

src/LogExpert.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{848C24BA
7676
EndProject
7777
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SftpFileSystem.Resources", "SftpFileSystem.Resources\SftpFileSystem.Resources.csproj", "{201CE6E2-776D-40B2-91B1-6AC578374385}"
7878
EndProject
79+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogExpert.PluginRegistry.Tests", "PluginRegistry.Tests\LogExpert.PluginRegistry.Tests.csproj", "{27EF66B7-C90C-7D5C-BD53-113DB43DF578}"
80+
EndProject
7981
Global
8082
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8183
Debug|Any CPU = Debug|Any CPU
@@ -168,6 +170,10 @@ Global
168170
{201CE6E2-776D-40B2-91B1-6AC578374385}.Debug|Any CPU.Build.0 = Debug|Any CPU
169171
{201CE6E2-776D-40B2-91B1-6AC578374385}.Release|Any CPU.ActiveCfg = Release|Any CPU
170172
{201CE6E2-776D-40B2-91B1-6AC578374385}.Release|Any CPU.Build.0 = Release|Any CPU
173+
{27EF66B7-C90C-7D5C-BD53-113DB43DF578}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
174+
{27EF66B7-C90C-7D5C-BD53-113DB43DF578}.Debug|Any CPU.Build.0 = Debug|Any CPU
175+
{27EF66B7-C90C-7D5C-BD53-113DB43DF578}.Release|Any CPU.ActiveCfg = Release|Any CPU
176+
{27EF66B7-C90C-7D5C-BD53-113DB43DF578}.Release|Any CPU.Build.0 = Release|Any CPU
171177
EndGlobalSection
172178
GlobalSection(SolutionProperties) = preSolution
173179
HideSolutionNode = FALSE
@@ -184,6 +190,7 @@ Global
184190
{B57259A3-4ED7-4F8B-A252-29E799A56B9E} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
185191
{C625E7C2-AF15-4C40-8C35-3E166D46F939} = {DE6375A4-B4C4-4620-8FFB-B9D5A4E21144}
186192
{FBFB598D-B94A-4AD3-A355-0D5A618CEEE3} = {848C24BA-BEBA-48EC-90E6-526ECAB6BB4A}
193+
{27EF66B7-C90C-7D5C-BD53-113DB43DF578} = {848C24BA-BEBA-48EC-90E6-526ECAB6BB4A}
187194
EndGlobalSection
188195
GlobalSection(ExtensibilityGlobals) = postSolution
189196
SolutionGuid = {15924D5F-B90B-4BC7-9E7D-BCCB62EBABAD}
File renamed without changes.

src/PluginRegistry.Tests/AssemblyInspectorTests.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public void InspectAssembly_WithNullPath_ReturnsEmptyInfo()
1414
var result = AssemblyInspector.InspectAssembly(null);
1515

1616
// Assert
17-
Assert.IsNotNull(result);
18-
Assert.IsTrue(result.IsEmpty);
17+
Assert.That(result, Is.Not.Null);
18+
Assert.That(result.IsEmpty, Is.True);
1919
}
2020

2121
[Test]
@@ -25,8 +25,8 @@ public void InspectAssembly_WithEmptyPath_ReturnsEmptyInfo()
2525
var result = AssemblyInspector.InspectAssembly(string.Empty);
2626

2727
// Assert
28-
Assert.IsNotNull(result);
29-
Assert.IsTrue(result.IsEmpty);
28+
Assert.That(result, Is.Not.Null);
29+
Assert.That(result.IsEmpty, Is.True);
3030
}
3131

3232
[Test]
@@ -39,8 +39,8 @@ public void InspectAssembly_WithNonExistentFile_ReturnsEmptyInfo()
3939
var result = AssemblyInspector.InspectAssembly(nonExistentPath);
4040

4141
// Assert
42-
Assert.IsNotNull(result);
43-
Assert.IsTrue(result.IsEmpty);
42+
Assert.That(result, Is.Not.Null);
43+
Assert.That(result.IsEmpty, Is.True);
4444
}
4545

4646
[Test]
@@ -56,8 +56,8 @@ public void InspectAssembly_WithInvalidDll_ReturnsEmptyInfo()
5656
var result = AssemblyInspector.InspectAssembly(tempFile);
5757

5858
// Assert
59-
Assert.IsNotNull(result);
60-
Assert.IsTrue(result.IsEmpty);
59+
Assert.That(result, Is.Not.Null);
60+
Assert.That(result.IsEmpty, Is.True);
6161
}
6262
finally
6363
{
@@ -78,7 +78,7 @@ public void IsLikelyPluginAssembly_WithColumnizerInName_ReturnsTrue()
7878
var result = AssemblyInspector.IsLikelyPluginAssembly(path);
7979

8080
// Assert
81-
Assert.IsTrue(result);
81+
Assert.That(result, Is.True);
8282
}
8383

8484
[Test]
@@ -91,7 +91,7 @@ public void IsLikelyPluginAssembly_WithPluginInName_ReturnsTrue()
9191
var result = AssemblyInspector.IsLikelyPluginAssembly(path);
9292

9393
// Assert
94-
Assert.IsTrue(result);
94+
Assert.That(result, Is.True);
9595
}
9696

9797
[Test]
@@ -104,7 +104,7 @@ public void IsLikelyPluginAssembly_WithFileSystemInName_ReturnsTrue()
104104
var result = AssemblyInspector.IsLikelyPluginAssembly(path);
105105

106106
// Assert
107-
Assert.IsTrue(result);
107+
Assert.That(result, Is.True);
108108
}
109109

110110
[Test]
@@ -117,7 +117,7 @@ public void IsLikelyPluginAssembly_WithHighlighterInName_ReturnsTrue()
117117
var result = AssemblyInspector.IsLikelyPluginAssembly(path);
118118

119119
// Assert
120-
Assert.IsTrue(result);
120+
Assert.That(result, Is.True);
121121
}
122122

123123
[Test]
@@ -130,7 +130,7 @@ public void IsLikelyPluginAssembly_WithNormalDllName_ReturnsFalse()
130130
var result = AssemblyInspector.IsLikelyPluginAssembly(path);
131131

132132
// Assert
133-
Assert.IsFalse(result);
133+
Assert.That(result, Is.False);
134134
}
135135

136136
[Test]
@@ -140,7 +140,7 @@ public void IsLikelyPluginAssembly_WithNullPath_ReturnsFalse()
140140
var result = AssemblyInspector.IsLikelyPluginAssembly(null);
141141

142142
// Assert
143-
Assert.IsFalse(result);
143+
Assert.That(result, Is.False);
144144
}
145145

146146
[Test]
@@ -150,7 +150,7 @@ public void IsLikelyPluginAssembly_WithEmptyPath_ReturnsFalse()
150150
var result = AssemblyInspector.IsLikelyPluginAssembly(string.Empty);
151151

152152
// Assert
153-
Assert.IsFalse(result);
153+
Assert.That(result, Is.False);
154154
}
155155

156156
// NOTE: Integration tests that load actual plugin DLLs should be in a separate test class

src/PluginRegistry.Tests/LazyPluginLoaderTests.cs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,24 @@ public void Constructor_WithValidPath_CreatesInstance()
1313
{
1414
// Arrange
1515
var dllPath = "test.dll";
16-
var manifest = new PluginManifest { Name = "TestPlugin", Version = "1.0.0" };
16+
var manifest = new PluginManifest
17+
{
18+
Name = "TestPlugin",
19+
Version = "1.0.0",
20+
Author = "Test",
21+
Description = "Test Plugin",
22+
ApiVersion = "1.0",
23+
Main = "test.dll"
24+
};
1725

1826
// Act
1927
var loader = new LazyPluginLoader<ILogLineColumnizer>(dllPath, manifest);
2028

2129
// Assert
22-
Assert.IsNotNull(loader);
23-
Assert.AreEqual(dllPath, loader.DllPath);
24-
Assert.AreEqual(manifest, loader.Manifest);
25-
Assert.IsFalse(loader.IsLoaded);
30+
Assert.That(loader, Is.Not.Null);
31+
Assert.That(loader.DllPath, Is.EqualTo(dllPath));
32+
Assert.That(loader.Manifest, Is.EqualTo(manifest));
33+
Assert.That(loader.IsLoaded, Is.False);
2634
}
2735

2836
[Test]
@@ -35,10 +43,10 @@ public void Constructor_WithNullManifest_CreatesInstance()
3543
var loader = new LazyPluginLoader<ILogLineColumnizer>(dllPath, null);
3644

3745
// Assert
38-
Assert.IsNotNull(loader);
39-
Assert.AreEqual(dllPath, loader.DllPath);
40-
Assert.IsNull(loader.Manifest);
41-
Assert.IsFalse(loader.IsLoaded);
46+
Assert.That(loader, Is.Not.Null);
47+
Assert.That(loader.DllPath, Is.EqualTo(dllPath));
48+
Assert.That(loader.Manifest, Is.Null);
49+
Assert.That(loader.IsLoaded, Is.False);
4250
}
4351

4452
[Test]
@@ -60,8 +68,8 @@ public void GetInstance_WithNonExistentFile_ReturnsNull()
6068
var instance = loader.GetInstance();
6169

6270
// Assert
63-
Assert.IsNull(instance);
64-
Assert.IsTrue(loader.IsLoaded); // Marked as loaded even on failure
71+
Assert.That(instance, Is.Null);
72+
Assert.That(loader.IsLoaded, Is.True); // Marked as loaded even on failure
6573
}
6674

6775
[Test]
@@ -76,8 +84,8 @@ public void GetInstance_CalledTwice_ReturnsSameInstance()
7684
var instance2 = loader.GetInstance();
7785

7886
// Assert
79-
Assert.AreSame(instance1, instance2);
80-
Assert.IsTrue(loader.IsLoaded);
87+
Assert.That(instance1, Is.SameAs(instance2));
88+
Assert.That(loader.IsLoaded, Is.True);
8189
}
8290

8391
[Test]
@@ -87,7 +95,7 @@ public void IsLoaded_BeforeGetInstance_ReturnsFalse()
8795
var loader = new LazyPluginLoader<ILogLineColumnizer>("test.dll", null);
8896

8997
// Assert
90-
Assert.IsFalse(loader.IsLoaded);
98+
Assert.That(loader.IsLoaded, Is.False);
9199
}
92100

93101
[Test]
@@ -101,7 +109,7 @@ public void IsLoaded_AfterGetInstance_ReturnsTrue()
101109
_ = loader.GetInstance();
102110

103111
// Assert
104-
Assert.IsTrue(loader.IsLoaded);
112+
Assert.That(loader.IsLoaded, Is.True);
105113
}
106114

107115
[Test]
@@ -115,7 +123,7 @@ public void ToString_ReturnsFormattedString()
115123
var result = loader.ToString();
116124

117125
// Assert
118-
Assert.IsNotNull(result);
126+
Assert.That(result, Is.Not.Null);
119127
Assert.That(result, Does.Contain("LazyPluginLoader"));
120128
Assert.That(result, Does.Contain("ILogLineColumnizer"));
121129
Assert.That(result, Does.Contain("TestPlugin.dll"));
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
5+
<IsTestProject>true</IsTestProject>
6+
<AssemblyTitle>LogExpert.PluginRegistry.Tests</AssemblyTitle>
7+
<Company>Microsoft</Company>
8+
<OutputPath>bin\$(Configuration)</OutputPath>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<ProjectReference Include="..\PluginRegistry\LogExpert.PluginRegistry.csproj" />
12+
<ProjectReference Include="..\ColumnizerLib\ColumnizerLib.csproj" />
13+
<ProjectReference Include="..\LogExpert.Core\LogExpert.Core.csproj" />
14+
</ItemGroup>
15+
<ItemGroup>
16+
<PackageReference Include="NUnit" />
17+
<PackageReference Include="NUnit3TestAdapter" />
18+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
19+
<PackageReference Include="Moq" />
20+
</ItemGroup>
21+
</Project>

src/LogExpert.Tests/PluginRegistry/PathTraversalProtectionTests.cs renamed to src/PluginRegistry.Tests/PathTraversalProtectionTests.cs

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)