From 95fb94dc54af4baf87e9d605faab65e6ed930ed1 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Thu, 4 Jan 2024 01:35:25 +1100 Subject: [PATCH] Add Header test --- .../Extensions/KeyValuesExtensionsTests.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/HUDMergerTests/Extensions/KeyValuesExtensionsTests.cs diff --git a/src/HUDMergerTests/Extensions/KeyValuesExtensionsTests.cs b/src/HUDMergerTests/Extensions/KeyValuesExtensionsTests.cs new file mode 100644 index 0000000..2629ee9 --- /dev/null +++ b/src/HUDMergerTests/Extensions/KeyValuesExtensionsTests.cs @@ -0,0 +1,34 @@ +using System; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using VDF.Models; + +namespace HUDMerger.Extensions.Tests; + +[TestClass()] +public class KeyValuesExtensionsTests +{ + [TestMethod()] + public void HeaderTest() + { + // Header + Assert.AreEqual([], new KeyValues([new KeyValue { Key = "Resource/HudLayout.res", Value = new KeyValues(), Conditional = null }]).Header()); + + // Ignore conditional + Assert.AreEqual([], new KeyValues([new KeyValue { Key = "Resource/HudLayout.res", Value = new KeyValues(), Conditional = "[$WIN32]" }]).Header()); + + // Replace string + Assert.AreEqual([], new KeyValues([new KeyValue { Key = "Resource/HudLayout.res", Value = "", Conditional = null }]).Header()); + + // Return KeyValues + Assert.AreEqual([], new KeyValues().Header()); + + // Append Header + KeyValues keyValues = []; + Assert.AreEqual([], keyValues.Header("Resource/HudLayout.res")); + Assert.IsTrue(keyValues.Any((kv) => kv.Key == "Resource/HudLayout.res" && kv.Value is KeyValues)); + + // hudanimations_manifest (https://github.com/cooolbros/hud-merger/issues/3) + Assert.AreEqual([], new KeyValues().Header("hudanimations_manifest")); + } +}