I am wondering if semantic HTML comparison is supported using .cs files for unit tests written using bUnit. I represent a probably very small group of people that cannot write unit tests using razor files. The reason would take too long to explain than what it is worth. Is this possible in the .cs files? Will it be supported in the future?
Yes. The semantic comparer is exposed via the MarkupMatches
method, and you can use that from wherever you want.
The advantage of writing markup in .razor files is that you can get syntax highlighting and editor help. However, with C# 11 new multiline string syntax, a lot of the issues with html markup in strings goes away, since you now don't have to escape "
quotes any more, so that makes things a whole lot easier in .cs files too.
Learn more here: