The TestResults library supports saving test results to TRX files.
The following code-snippet shows how to create a TRX test-results file.
// Create a TestResults instance
var results = new TestResults{Name = "SomeTests"};
// Add some results
results.Results.Add(
new TestResult{
Name = "Test1",
ClassName = "SomeTestClass",
CodeBase = "MyTestAssembly",
Outcome = TestOutcome.Passed
});
// Save the results to file
File.WriteAllText(
"results.trx",
TrxSerializer.Serialize(results));