I would make an extension method for HtmlHelper as follows
public static MvcHtmlString GetFailedClass(this HtmlHelper html, bool condition) { if(!condition) return MvcHtmlString.Create("trFailedTestRun") }
And then in sight
<tr class="@Html.GetFailedClass(charlieTestRunViewModel.Succeeded)">
source share