Append record stub & union pattern match case

This PR contains the previous one (#480) and contains union pattern match case appending instead of prepending.

You may want to merge the previous PR before this one.
I think the full name `CodeGenerationTestInfrastructure` would be better. `Infra` isn't a common abbreviation.