diff --git a/src/Blocktavius.AppDQB2/AssemblyInfo.cs b/src/Blocktavius.AppDQB2/AssemblyInfo.cs index d9a1bde..10caf64 100644 --- a/src/Blocktavius.AppDQB2/AssemblyInfo.cs +++ b/src/Blocktavius.AppDQB2/AssemblyInfo.cs @@ -1,3 +1,4 @@ +using System.Runtime.CompilerServices; using System.Windows; [assembly: ThemeInfo( @@ -8,3 +9,5 @@ //(used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] + +[assembly: InternalsVisibleTo("Blocktavius.AppDQB2Tests")] diff --git a/src/Blocktavius.AppDQB2/Persistence/PolymorphicTypeResolver.cs b/src/Blocktavius.AppDQB2/Persistence/PolymorphicTypeResolver.cs index 56ec5e9..8c108d6 100644 --- a/src/Blocktavius.AppDQB2/Persistence/PolymorphicTypeResolver.cs +++ b/src/Blocktavius.AppDQB2/Persistence/PolymorphicTypeResolver.cs @@ -53,7 +53,11 @@ private static IEnumerable DiscoverHillDesignerTypes() => private static IEnumerable<(Type type, TAttr attr)> DiscoverTypes(Type interfaceType) where TAttr : System.Attribute { + // Filter out Microsoft to avoid this error in unit tests: + // Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. + // See also https://github.com/microsoft/testfx/issues/2609 var types = AppDomain.CurrentDomain.GetAssemblies() + .Where(a => a.FullName?.StartsWith("Microsoft") == false) .SelectMany(asm => asm.GetTypes()) .Where(t => t.IsClass && !t.IsAbstract && interfaceType.IsAssignableFrom(t)) .ToList(); diff --git a/src/Blocktavius.AppDQB2Tests/Blocktavius.AppDQB2Tests.csproj b/src/Blocktavius.AppDQB2Tests/Blocktavius.AppDQB2Tests.csproj new file mode 100644 index 0000000..35d9144 --- /dev/null +++ b/src/Blocktavius.AppDQB2Tests/Blocktavius.AppDQB2Tests.csproj @@ -0,0 +1,19 @@ + + + + net9.0-windows7.0 + latest + enable + enable + + true + + + + + + + diff --git a/src/Blocktavius.AppDQB2Tests/MSTestSettings.cs b/src/Blocktavius.AppDQB2Tests/MSTestSettings.cs new file mode 100644 index 0000000..aaf278c --- /dev/null +++ b/src/Blocktavius.AppDQB2Tests/MSTestSettings.cs @@ -0,0 +1 @@ +[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)] diff --git a/src/Blocktavius.AppDQB2Tests/Test1.cs b/src/Blocktavius.AppDQB2Tests/Test1.cs new file mode 100644 index 0000000..4a4d358 --- /dev/null +++ b/src/Blocktavius.AppDQB2Tests/Test1.cs @@ -0,0 +1,54 @@ +using Blocktavius.AppDQB2.Persistence.V1; + +namespace Blocktavius.AppDQB2Tests; + +[TestClass] +public sealed class Test1 +{ + [TestMethod] + public void TestMethod1() + { + const string json = + """ + { + "ProfileVerificationHash": "SwsLltjL\u002B/NQCgJQGj9kgJhDXTrXlTXHz7cI/fgxuII=", + "SourceSlot": { + "SlotNumber": 3, + "SlotName": "Slot 3 (B02)" + }, + "DestSlot": { + "SlotNumber": 1, + "SlotName": "Slot 1 (B00)" + }, + "SourceStgdatFilename": "STGDAT16.BIN", + "ChunkExpansion": [], + "Notes": "", + "Images": [], + "MinimapVisible": true, + "ChunkGridVisible": true, + "Scripts": [ + { + "ScriptName": "Script 1", + "ScriptNodes": [ + { + "$type": "bad discriminator", + "Elevation": 74, + "HillDesigner": { + "$type": "WinsomeHill-4380", + "Steepness": 2 + }, + "AreaPersistId": "IMG:export\\plateaus\\p1.png", + "BlockPersistId": "BLK:12", + "LockRandomSeed": false + } + ] + } + ], + "SelectedScriptIndex": 11 + } + """; + + var project = ProjectV1.Load(json); + Assert.IsNotNull(project); + } +} diff --git a/src/Blocktavius.sln b/src/Blocktavius.sln index f24dc0b..daad611 100644 --- a/src/Blocktavius.sln +++ b/src/Blocktavius.sln @@ -18,6 +18,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antipasta", "Antipasta\Antipasta.csproj", "{098197E3-A33F-4D06-B6ED-FA61032DE307}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blocktavius.AppDQB2Tests", "Blocktavius.AppDQB2Tests\Blocktavius.AppDQB2Tests.csproj", "{DA50C9A5-B158-4162-9C81-DB1086B55D16}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -44,6 +46,10 @@ Global {098197E3-A33F-4D06-B6ED-FA61032DE307}.Debug|Any CPU.Build.0 = Debug|Any CPU {098197E3-A33F-4D06-B6ED-FA61032DE307}.Release|Any CPU.ActiveCfg = Release|Any CPU {098197E3-A33F-4D06-B6ED-FA61032DE307}.Release|Any CPU.Build.0 = Release|Any CPU + {DA50C9A5-B158-4162-9C81-DB1086B55D16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA50C9A5-B158-4162-9C81-DB1086B55D16}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA50C9A5-B158-4162-9C81-DB1086B55D16}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA50C9A5-B158-4162-9C81-DB1086B55D16}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE