How to use rsyslog templates to write log files based on a wildcard syslog facility?

SyslogIdentifier= and test-0 are not a facility but a program name. Replace %syslogfacility-text% by %programname% and use a legacy property filter selector like

:programname, startswith, "test-"  ?TestFile