Skip to content

Binary values output in AssertEqualsTable #216

Description

@ovcharenko-di

My actual\expected tables has columns with binary(16) type.
I populate expected table with following:

('2023-08-15', '2023-08-20', 'C', 0x33333333333333333333333333333333, 0xCCCC3333333333333333333333333333, N'Group C', N'Clear C'),

However, when I run my test with AssertEqualsTable, the difference between binary values are listed as System.Byte[].
Is there any way to output binary in the human-readable form? Or, if not, is there convenient workaround?

Image

Activity

  1. ovcharenko-di commented on Jul 16, 2025

    @ovcharenko-di
    Author

    DeepSeek gave me a workaround:

    In the test, after populating expected and actual tables, create views in which binary values are converted to the desired format. In AssertEqualsTable, replace original tables with views.

    -- above this line goes your test and then:
    
    EXEC(
      'CREATE VIEW TableActual_Converted AS
         SELECT 
            a,
            CONVERT(varchar(32), b, 2) AS b_hex, -- here comes the conversion
            c
        FROM TableActual;'
    );
    
    EXEC(
      'CREATE VIEW TableExpected_Converted AS
         SELECT 
            a,
            CONVERT(varchar(32), b, 2) AS b_hex, -- here comes the conversion
            c
        FROM TableExpected;'
    );
    
    EXEC tSQLt.AssertEqualsTable 'TableExpected_Converted ',  'TableActual_Converted ';

    It clutters the test a little bit, but works just fine.
    I think the issue can be closed if there is no better solution in place. If there is - please, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions