KingslandConsulting / Kingsland.MofParser

A C# library for parsing the contents of Managed Object Format (MOF) files
GNU Lesser General Public License v3.0
25 stars 4 forks source link

Clean up mof source text in unit tests #73

Closed mikeclayton closed 3 years ago

mikeclayton commented 3 years ago

Related to #72.

At the moment the literal strings as "expected" output from the AstMofGenerator are pretty ugly - e.g.

AssociationDeclarationWithSuperAssociationShouldRoundtrip()

var sourceText =
    "association GOLF_MemberLocker : GOLF_Base\r\n" +
    "{\r\n" +
    "\tGOLF_ClubMember REF Member;\r\n" +
    "\tGOLF_Locker REF Locker;\r\n" +
    "\tGOLF_Date AssignedOnDate;\r\n" +
    "};";

It would be nice if we could do something like this instead with a multi-line string that uses a custom indent - e.g. " " vs "\t"

var sourceText = @"
    association GOLF_MemberLocker : GOLF_Base
    {
        GOLF_ClubMember REF Member;
        GOLF_Locker REF Locker;
        GOLF_Date AssignedOnDate;
    };
    @";

Note the literal string will have additional indenting and leading / trailing line breaks - e.g.:


    association GOLF_MemberLocker : GOLF_Base
    {
        GOLF_ClubMember REF Member;
        GOLF_Locker REF Locker;
        GOLF_Date AssignedOnDate;
    };

so we might need a couple of helper functions to remove the indent and line breaks so the resulting string is:

association GOLF_MemberLocker : GOLF_Base
{
    GOLF_ClubMember REF Member;
    GOLF_Locker REF Locker;
    GOLF_Date AssignedOnDate;
};