Unit tests for VmatWriter. Verifies the generated VMAT text includes an auto-generated header, references the complex shader, embeds provided texture paths, respects byte-level UTF8 encoding for the header, and includes flags and self-illum texture entries when requested.
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using GmodAssetImporter;
[TestClass]
public class VmatWriterTests
{
[TestMethod]
public void EmitsAutoGeneratedHeaderAndComplexShader()
{
var text = VmatWriter.Build( new VmatWriteRequest
{
ColorTextureAssetPath = "materials/test/source_files/gun_color.png",
NormalTextureAssetPath = "materials/test/source_files/gun_normal.png"
} );
Assert.IsTrue( text.StartsWith( "// THIS FILE IS AUTO-GENERATED" ) );
Assert.IsTrue( text.Contains( "shaders/complex.shader" ) );
Assert.IsTrue( text.Contains( "TextureColor \"materials/test/source_files/gun_color.png\"" ) );
Assert.IsTrue( text.Contains( "TextureNormal \"materials/test/source_files/gun_normal.png\"" ) );
var bytes = new UTF8Encoding( false ).GetBytes( text );
Assert.AreEqual( (byte)'/', bytes[0] );
Assert.AreEqual( (byte)'/', bytes[1] );
}
[TestMethod]
public void IncludesTranslucentAndSelfIllumWhenRequested()
{
var text = VmatWriter.Build( new VmatWriteRequest
{
ColorTextureAssetPath = "materials/a/source_files/a_color.png",
Translucent = true,
SelfIllumTextureAssetPath = "materials/a/source_files/a_selfillum.png"
} );
Assert.IsTrue( text.Contains( "F_TRANSLUCENT 1" ) );
Assert.IsTrue( text.Contains( "F_SELF_ILLUM 1" ) );
Assert.IsTrue( text.Contains( "TextureSelfIllumMask" ) );
}
}