protected void AssertEqual(CodeObject c, string expected)
{
// Validate all identifiers are valid
CodeGenerator.ValidateIdentifiers(c);
// Generate code
CodeDomProvider provider = GetProvider();
string code = GenerateCode(c, provider);
// Make sure the code matches what we expected
try
{
Assert.Equal(CoalesceWhitespace(expected), CoalesceWhitespace(code));
}
catch
{
Console.WriteLine(code);
throw;
}
// Serialize and deserialize the CodeObject, and make sure code generated for it
// is the same as the original.
CodeObject clone = BinaryFormatterHelpers.Clone(c);
string cloneCode = GenerateCode(clone, provider);
Assert.Equal(code, cloneCode);
}