Unit tests for VmtParser. They validate parsing of VMT shader text, checking shader name, base texture, bump map, and boolean flags, and that comments and nested blocks are ignored.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using GmodAssetImporter;
[TestClass]
public class VmtParserTests
{
[TestMethod]
public void ParsesBaseTextureAndFlags()
{
const string vmt = """
"VertexLitGeneric"
{
"$basetexture" "models/weapons/v_pistol/v_hand_gun"
"$bumpmap" "models/weapons/v_pistol/v_hand_gun_normal"
"$translucent" "1"
"$selfillum" 1
}
""";
var data = VmtParser.Parse( vmt );
Assert.AreEqual( "VertexLitGeneric", data.Shader );
Assert.AreEqual( "models/weapons/v_pistol/v_hand_gun", data.BaseTexture );
Assert.AreEqual( "models/weapons/v_pistol/v_hand_gun_normal", data.BumpMap );
Assert.IsTrue( data.Translucent );
Assert.IsTrue( data.SelfIllum );
}
[TestMethod]
public void IgnoresCommentsAndNestedBlocks()
{
const string vmt = """
UnlitGeneric
{
// comment
"$basetexture" "foo/bar"
"Proxies"
{
"Something" { "resultVar" "$color" }
}
}
""";
var data = VmtParser.Parse( vmt );
Assert.AreEqual( "foo/bar", data.BaseTexture );
Assert.IsFalse( data.Params.ContainsKey( "Proxies" ) );
}
}