Skip to content

Commit 0a4d86f

Browse files
committed
strip windows/wpf
1 parent ee17522 commit 0a4d86f

5 files changed

Lines changed: 64 additions & 65 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*.user
1515
*.userosscache
1616
*.sln.docstates
17+
.idea/
1718

1819
# Build results
1920
[Dd]ebug/

Datamodel.NET.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6.0-windows</TargetFramework>
3+
<TargetFramework>net6.0</TargetFramework>
44
<OutputType>Library</OutputType>
55
<RootNamespace>Datamodel</RootNamespace>
66
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
77
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
8-
<UseWPF>true</UseWPF>
98
<NoWarn>IDE0018</NoWarn>
109
</PropertyGroup>
1110
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -40,10 +39,4 @@
4039
<Compile Remove="Tests\Properties\AssemblyInfo.cs" />
4140
<Compile Remove="Tests\Tests.cs" />
4241
</ItemGroup>
43-
<ItemGroup>
44-
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.346202">
45-
<PrivateAssets>all</PrivateAssets>
46-
</PackageReference>
47-
<PackageReference Include="System.Resources.Extensions" Version="6.0.0" />
48-
</ItemGroup>
4942
</Project>

Datamodel.NET.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio Version 17
43
VisualStudioVersion = 17.3.32901.215
@@ -18,8 +17,6 @@ Global
1817
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1918
{075743A9-B292-410C-B68F-6E6CF588D60A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2019
{075743A9-B292-410C-B68F-6E6CF588D60A}.Debug|Any CPU.Build.0 = Debug|Any CPU
21-
{075743A9-B292-410C-B68F-6E6CF588D60A}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
22-
{075743A9-B292-410C-B68F-6E6CF588D60A}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
2320
{075743A9-B292-410C-B68F-6E6CF588D60A}.Release|Any CPU.ActiveCfg = Release|Any CPU
2421
{075743A9-B292-410C-B68F-6E6CF588D60A}.Release|Any CPU.Build.0 = Release|Any CPU
2522
{4C928D60-5E48-4C0D-9C7E-C75D9734CD58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

Tests/Tests.cs

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Diagnostics;
55
using System.Linq;
66
using System.IO;
7-
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using NUnit.Framework;
88
using Datamodel;
99
using System.Numerics;
1010
using DM = Datamodel.Datamodel;
@@ -37,13 +37,19 @@ static DatamodelTests()
3737
TestValues_V3 = TestValues_V1.Concat(new object[] { (byte)0xFF, (UInt64)0xFFFFFFFF }).ToList();
3838
}
3939

40-
public TestContext TestContext { get; set; }
4140

42-
protected string OutPath => Path.Combine(TestContext.TestResultsDirectory, TestContext.TestName);
43-
protected string DmxSavePath { get { return OutPath + ".dmx"; } }
44-
protected string DmxConvertPath { get { return OutPath + "_convert.dmx"; } }
41+
protected static string OutPath
42+
=> Path.Combine(TestContext.CurrentContext.TestDirectory, TestContext.CurrentContext.Test.Name);
43+
protected static string DmxSavePath { get { return OutPath + ".dmx"; } }
44+
protected static string DmxConvertPath { get { return OutPath + "_convert.dmx"; } }
4545

46-
protected void Cleanup()
46+
protected static string[] GetDmxFiles()
47+
{
48+
var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources");
49+
return Directory.GetFiles(path, "*.dmx");
50+
}
51+
52+
protected static void Cleanup()
4753
{
4854
File.Delete(DmxSavePath);
4955
if (DmxConvertExe_Exists)
@@ -57,12 +63,13 @@ protected static DM MakeDatamodel()
5763
return new DM("model", 1); // using "model" to keep dxmconvert happy
5864
}
5965

60-
protected bool SaveAndConvert(Datamodel.Datamodel dm, string encoding, int version)
66+
protected static bool SaveAndConvert(DM datamodel, string encoding, int version)
6167
{
62-
dm.Save(DmxSavePath, encoding, version);
68+
datamodel.Save(DmxSavePath, encoding, version);
6369

6470
if (!DmxConvertExe_Exists)
6571
{
72+
Assert.Warn("dmxconvert.exe not available.");
6673
return false;
6774
}
6875

@@ -71,25 +78,22 @@ protected bool SaveAndConvert(Datamodel.Datamodel dm, string encoding, int versi
7178
StartInfo = new ProcessStartInfo()
7279
{
7380
FileName = DmxConvertExe,
74-
Arguments = String.Format("-i \"{0}\" -o \"{1}\" -oe {2}", DmxSavePath, DmxConvertPath, encoding),
81+
Arguments = string.Format("-i \"{0}\" -o \"{1}\" -oe {2}", DmxSavePath, DmxConvertPath, encoding),
7582
UseShellExecute = false,
7683
CreateNoWindow = true,
7784
RedirectStandardOutput = true,
7885
RedirectStandardError = true,
7986
}
8087
};
8188

82-
Console.WriteLine(String.Join(" ", dmxconvert.StartInfo.FileName, dmxconvert.StartInfo.Arguments));
89+
Console.WriteLine($"Converting {TestContext.CurrentContext.Test.Name}.dmx to {encoding}");
8390

8491
dmxconvert.Start();
8592
var err = dmxconvert.StandardOutput.ReadToEnd();
8693
err += dmxconvert.StandardError.ReadToEnd();
8794
dmxconvert.WaitForExit();
8895

89-
Console.WriteLine(err);
90-
91-
if (dmxconvert.ExitCode != 0)
92-
throw new AssertFailedException(err);
96+
Assert.That(dmxconvert.ExitCode, Is.Zero, $"dmxconvert failed to convert the file with error: {err}");
9397

9498
return true;
9599
}
@@ -99,16 +103,16 @@ protected bool SaveAndConvert(Datamodel.Datamodel dm, string encoding, int versi
99103
/// </summary>
100104
protected static void PrintContents(DM dm)
101105
{
102-
System.Threading.Tasks.Parallel.ForEach<Datamodel.Element>(dm.AllElements, e =>
106+
System.Threading.Tasks.Parallel.ForEach(dm.AllElements, e =>
103107
{
104108
System.Threading.Tasks.Parallel.ForEach(e, a => {; });
105109
});
106110
}
107111

108-
protected static List<object> TestValues_V1;
109-
protected static List<object> TestValues_V2;
110-
protected static List<object> TestValues_V3;
111-
protected static Guid RootGuid = Guid.NewGuid();
112+
protected static List<object> TestValues_V1 { get; }
113+
protected static List<object> TestValues_V2 { get; }
114+
protected static List<object> TestValues_V3 { get; }
115+
protected static Guid RootGuid { get; } = Guid.NewGuid();
112116

113117
protected static List<object> AttributeValuesFor(string encoding_name, int encoding_version)
114118
{
@@ -215,53 +219,53 @@ protected DM Create(string encoding, int version, bool memory_save = false)
215219
}
216220

217221
dm.AllElements.Remove(dm.Root.GetArray<Element>("ElemArray")[3], DM.ElementList.RemoveMode.MakeStubs);
218-
Assert.AreEqual<bool>(true, dm.Root.GetArray<Element>("ElemArray")[3].Stub);
222+
Assert.AreEqual(true, dm.Root.GetArray<Element>("ElemArray")[3].Stub);
219223

220224
dm.AllElements.Remove(dm.Root, DM.ElementList.RemoveMode.MakeStubs);
221-
Assert.AreEqual<bool>(true, dm.Root.Stub);
225+
Assert.AreEqual(true, dm.Root.Stub);
222226

223227
return dm;
224228
}
225229
}
226230

227-
[TestClass]
231+
[TestFixture]
228232
public class Functionality : DatamodelTests
229233
{
230234

231-
[TestMethod]
235+
[Test]
232236
public void Create_Binary_9()
233237
{
234238
Create("binary", 9);
235239
}
236-
[TestMethod]
240+
[Test]
237241
public void Create_Binary_5()
238242
{
239243
Create("binary", 5);
240244
}
241-
[TestMethod]
245+
[Test]
242246
public void Create_Binary_4()
243247
{
244248
Create("binary", 4);
245249
}
246-
[TestMethod]
250+
[Test]
247251
public void Create_Binary_3()
248252
{
249253
Create("binary", 3);
250254
}
251-
[TestMethod]
255+
[Test]
252256
public void Create_Binary_2()
253257
{
254258
Create("binary", 2);
255259
}
256260

257-
[TestMethod]
261+
[Test]
258262
public void Create_KeyValues2_4()
259263
{
260264
Create("keyvalues2", 4);
261265
}
262266

263267

264-
[TestMethod]
268+
[Test]
265269
public void Create_KeyValues2_1()
266270
{
267271
Create("keyvalues2", 1);
@@ -273,7 +277,7 @@ void Get_TF2(Datamodel.Datamodel dm)
273277
dm.FormatVersion = 22; // otherwise recent versions of dmxconvert fail
274278
}
275279

276-
[TestMethod]
280+
[Test]
277281
public void Dota2_Binary_9()
278282
{
279283
var dm = DM.Load(Binary_9_File);
@@ -284,7 +288,7 @@ public void Dota2_Binary_9()
284288
Cleanup();
285289
}
286290

287-
[TestMethod]
291+
[Test]
288292
public void TF2_Binary_5()
289293
{
290294
var dm = DM.Load(Binary_5_File);
@@ -295,7 +299,7 @@ public void TF2_Binary_5()
295299
Cleanup();
296300
}
297301

298-
[TestMethod]
302+
[Test]
299303
public void TF2_Binary_4()
300304
{
301305
var dm = DM.Load(Binary_4_File);
@@ -306,7 +310,7 @@ public void TF2_Binary_4()
306310
Cleanup();
307311
}
308312

309-
[TestMethod]
313+
[Test]
310314
public void TF2_KeyValues2_1()
311315
{
312316
var dm = DM.Load(KeyValues2_1_File);
@@ -317,7 +321,16 @@ public void TF2_KeyValues2_1()
317321
Cleanup();
318322
}
319323

320-
[TestMethod]
324+
[Test, TestCaseSource(nameof(GetDmxFiles))]
325+
public void Load(string path)
326+
{
327+
var dm = DM.Load(path);
328+
PrintContents(dm);
329+
dm.Dispose();
330+
}
331+
332+
333+
[Test]
321334
public void Import()
322335
{
323336
var dm = MakeDatamodel();
@@ -331,11 +344,11 @@ public void Import()
331344
}
332345
}
333346

334-
[TestClass]
347+
[TestFixture, Category("Performance")]
335348
public class Performance : DatamodelTests
336349
{
337350
const int Load_Iterations = 10;
338-
System.Diagnostics.Stopwatch Timer = new System.Diagnostics.Stopwatch();
351+
readonly Stopwatch Timer = new();
339352

340353
void Load(FileStream f)
341354
{
@@ -346,34 +359,35 @@ void Load(FileStream f)
346359
DM.Load(f, Datamodel.Codecs.DeferredMode.Disabled);
347360
if (i > 0)
348361
{
349-
Console.WriteLine(Timer.ElapsedMilliseconds);
362+
Console.Write(Timer.ElapsedMilliseconds + ", ");
350363
elapsed += Timer.ElapsedMilliseconds;
351364
}
352365
Timer.Restart();
353366
}
354367
Timer.Stop();
355368
Console.WriteLine("Average: {0}ms", elapsed / Load_Iterations);
356369
}
357-
[TestMethod]
370+
371+
[Test]
358372
public void Perf_Load_Binary5()
359373
{
360374
Load(Binary_5_File);
361375
}
362376

363-
[TestMethod]
377+
[Test]
364378
public void Perf_Load_KeyValues2_1()
365379
{
366380
Load(KeyValues2_1_File);
367381
}
368382

369-
[TestMethod]
383+
[Test]
370384
public void Perf_Create_Binary5()
371385
{
372386
foreach (var i in Enumerable.Range(0, 1000))
373387
Create("binary", 5, true);
374388
}
375389

376-
[TestMethod]
390+
[Test]
377391
public void Perf_CreateElements_Binary5()
378392
{
379393
var dm = MakeDatamodel();
@@ -389,7 +403,7 @@ public void Perf_CreateElements_Binary5()
389403
Cleanup();
390404
}
391405

392-
[TestMethod]
406+
[Test]
393407
public void Perf_CreateAttributes_Binary5()
394408
{
395409
var dm = MakeDatamodel();
@@ -416,7 +430,7 @@ static class Extensions
416430
{
417431
public static Type MakeListType(this Type t)
418432
{
419-
return typeof(System.Collections.Generic.List<>).MakeGenericType(t);
433+
return typeof(List<>).MakeGenericType(t);
420434
}
421435
}
422436
}

Tests/Tests.csproj

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6.0-windows</TargetFramework>
3+
<TargetFramework>net6.0</TargetFramework>
44
<OutputType>Library</OutputType>
55
<RootNamespace>Datamodel_Tests</RootNamespace>
66
<AssemblyName>Datamodel.NET-Tests</AssemblyName>
77
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
8-
<UseWPF>true</UseWPF>
9-
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
10-
8+
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
119
</PropertyGroup>
1210
<ItemGroup>
1311
<None Update="Resources\binary4.dmx">
@@ -27,12 +25,8 @@
2725
<ProjectReference Include="..\Datamodel.NET.csproj" />
2826
</ItemGroup>
2927
<ItemGroup>
30-
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.346202">
31-
<PrivateAssets>all</PrivateAssets>
32-
</PackageReference>
33-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
34-
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
35-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
36-
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
28+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
29+
<PackageReference Include="NUnit" Version="3.13.3" />
30+
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
3731
</ItemGroup>
3832
</Project>

0 commit comments

Comments
 (0)