Skip to content

Commit

Permalink
Upgrades MSTest.TestFramework
Browse files Browse the repository at this point in the history
Fixes dynamic loading of assemblies in test
  • Loading branch information
Atreyu committed Jan 5, 2025
1 parent 0459c43 commit 0f8904c
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 19 deletions.
2 changes: 1 addition & 1 deletion InkyCal.Data.Tests/InkyCal.Data.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PackageReference Include="MiniProfiler.EntityFrameworkCore" Version="4.5.4" />
<PackageReference Include="MiniProfiler.Shared" Version="4.5.4" />
<PackageReference Include="MSTest.TestAdapter" Version="3.7.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.7.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
14 changes: 11 additions & 3 deletions InkyCal.Data.Tests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@
},
"MSTest.TestFramework": {
"type": "Direct",
"requested": "[3.6.3, )",
"resolved": "3.6.3",
"contentHash": "jockRcUoLJMeHzLqFcMnZBrWy7tS32JP7shlepDDJuf5A6HO2PwAefXzhvprcWNkfpEwmR0KihSO2HRXwNbTng=="
"requested": "[3.7.0, )",
"resolved": "3.7.0",
"contentHash": "CRHONroYbAaxhVILTNS84gIaI3uRRVmj8Qd3+Mpia1AVwSz2JiQy0LlTqtS8p+TYWgN+8zHG6j17OaTz/P/eHw==",
"dependencies": {
"MSTest.Analyzers": "3.7.0"
}
},
"SonarAnalyzer.CSharp": {
"type": "Direct",
Expand Down Expand Up @@ -582,6 +585,11 @@
"resolved": "6.0.0",
"contentHash": "hqTM5628jSsQiv+HGpiq3WKBl2c8v1KZfby2J6Pr7pEPlK9waPdgEO6b8A/+/xn/yZ9ulv8HuqK71ONy2tg67A=="
},
"MSTest.Analyzers": {
"type": "Transitive",
"resolved": "3.7.0",
"contentHash": "6cW8FWzz6gr5MArL8GDNrw5c+afJtOMRyntFEzAdbgPHgH8DuLGMAyz8g38k/LMquewk3tOmbXoDIL/IACLKjg=="
},
"Newtonsoft.Json": {
"type": "Transitive",
"resolved": "13.0.1",
Expand Down
2 changes: 1 addition & 1 deletion InkyCal.Models.Tests/InkyCal.Models.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.7.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
Expand Down
14 changes: 11 additions & 3 deletions InkyCal.Models.Tests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@
},
"MSTest.TestFramework": {
"type": "Direct",
"requested": "[3.6.3, )",
"resolved": "3.6.3",
"contentHash": "jockRcUoLJMeHzLqFcMnZBrWy7tS32JP7shlepDDJuf5A6HO2PwAefXzhvprcWNkfpEwmR0KihSO2HRXwNbTng=="
"requested": "[3.7.0, )",
"resolved": "3.7.0",
"contentHash": "CRHONroYbAaxhVILTNS84gIaI3uRRVmj8Qd3+Mpia1AVwSz2JiQy0LlTqtS8p+TYWgN+8zHG6j17OaTz/P/eHw==",
"dependencies": {
"MSTest.Analyzers": "3.7.0"
}
},
"SonarAnalyzer.CSharp": {
"type": "Direct",
Expand Down Expand Up @@ -147,6 +150,11 @@
"Newtonsoft.Json": "13.0.1"
}
},
"MSTest.Analyzers": {
"type": "Transitive",
"resolved": "3.7.0",
"contentHash": "6cW8FWzz6gr5MArL8GDNrw5c+afJtOMRyntFEzAdbgPHgH8DuLGMAyz8g38k/LMquewk3tOmbXoDIL/IACLKjg=="
},
"Newtonsoft.Json": {
"type": "Transitive",
"resolved": "13.0.1",
Expand Down
2 changes: 1 addition & 1 deletion InkyCal.Utils.Tests/InkyCal.Utils.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.7.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.7.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
28 changes: 21 additions & 7 deletions InkyCal.Utils.Tests/PanelRenderHelperTests.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
using InkyCal.Utils;
using System;
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using InkyCal.Models;
using Xunit;
using System.Reflection;
using System.Threading;
using Xunit.Abstractions;

namespace InkyCal.Utils.Tests
{
public class PanelRenderHelperTests
public class PanelRenderHelperTests(ITestOutputHelper output)
{
private readonly ITestOutputHelper output = output;

[Fact()]
public void GetRendererTest()
{
//Arrange
//Get instance of all types inheriting from panel
var helper = new PanelRenderHelper(async (token, _) => await System.Threading.Tasks.Task.CompletedTask);
var panels = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(x => x.GetTypes())
.SelectMany(x =>
{
try
{
return x.GetTypes();
}
catch (ReflectionTypeLoadException ex) {
output.WriteLine($"Warning: Error while loading types from assembly: {x.FullName} => {ex}");
return Type.EmptyTypes;
}
})
.Where(x => typeof(Panel).IsAssignableFrom(x)
&& !x.Equals(typeof(Panel))
&& !x.IsInterface
&& !x.IsAbstract).Select(x => (Panel)x.GetConstructor(Type.EmptyTypes).Invoke(Array.Empty<object>()));
&& !x.IsAbstract).Select(x => (Panel)x.GetConstructor(Type.EmptyTypes).Invoke([]));

Assert.NotEmpty(panels);

//Act & assert
Assert.All(panels, x =>
{
Expand Down
14 changes: 11 additions & 3 deletions InkyCal.Utils.Tests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@
},
"MSTest.TestFramework": {
"type": "Direct",
"requested": "[3.6.3, )",
"resolved": "3.6.3",
"contentHash": "jockRcUoLJMeHzLqFcMnZBrWy7tS32JP7shlepDDJuf5A6HO2PwAefXzhvprcWNkfpEwmR0KihSO2HRXwNbTng=="
"requested": "[3.7.0, )",
"resolved": "3.7.0",
"contentHash": "CRHONroYbAaxhVILTNS84gIaI3uRRVmj8Qd3+Mpia1AVwSz2JiQy0LlTqtS8p+TYWgN+8zHG6j17OaTz/P/eHw==",
"dependencies": {
"MSTest.Analyzers": "3.7.0"
}
},
"SonarAnalyzer.CSharp": {
"type": "Direct",
Expand Down Expand Up @@ -398,6 +401,11 @@
"Microsoft.Extensions.DependencyInjection.Abstractions": "2.0.0"
}
},
"MSTest.Analyzers": {
"type": "Transitive",
"resolved": "3.7.0",
"contentHash": "6cW8FWzz6gr5MArL8GDNrw5c+afJtOMRyntFEzAdbgPHgH8DuLGMAyz8g38k/LMquewk3tOmbXoDIL/IACLKjg=="
},
"Newtonsoft.Json": {
"type": "Transitive",
"resolved": "13.0.3",
Expand Down

0 comments on commit 0f8904c

Please sign in to comment.