Unit test for FbxWriter.WriteMesh that creates a temporary directory, builds a simple triangle MeshExport with one bone, writes an ASCII FBX file, reads it back and asserts expected FBX content strings are present or absent.
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using GmodAssetImporter;
[TestClass]
public class FbxWriterTests
{
[TestMethod]
public void WritesAsciiFbxWithVertices()
{
var dir = Path.Combine( Path.GetTempPath(), "gmodassetimporter_fbx_" + System.Guid.NewGuid().ToString( "N" ) );
Directory.CreateDirectory( dir );
var path = Path.Combine( dir, "tri.fbx" );
try
{
var mesh = new MeshExport { Name = "tri" };
mesh.Vertices.Add( new MeshVertex { Position = new Vec3( 0, 0, 0 ) } );
mesh.Vertices.Add( new MeshVertex { Position = new Vec3( 1, 0, 0 ) } );
mesh.Vertices.Add( new MeshVertex { Position = new Vec3( 0, 1, 0 ) } );
mesh.Triangles.Add( new MeshTriangle { A = 0, B = 1, C = 2, MaterialName = "weapon_m9" } );
var bones = new System.Collections.Generic.List<BoneData>
{
new() { Name = "root", Parent = -1 }
};
FbxWriter.WriteMesh( path, bones, mesh );
var text = File.ReadAllText( path );
Assert.IsTrue( text.Contains( "FBXVersion: 7400" ) );
Assert.IsTrue( text.Contains( "Vertices:" ) );
Assert.IsTrue( text.Contains( "LayerElementMaterial:" ) );
Assert.IsTrue( text.Contains( "Material::weapon_m9" ) );
Assert.IsFalse( text.Contains( "Deformer:" ) ); // static bind-pose mesh, no skin clusters
}
finally
{
try { Directory.Delete( dir, true ); } catch { /* ignore */ }
}
}
}