0

I am currently comparing SQL Queries which can return thousands of values, into an List..

I'm using the ShouldBeEquivalentTo() in Fluent Assertion, but it takes forever, which is unacceptable. Anybody know how to do this in a fast matter?

With X-unit I used Assert.Equal but it fails comparing the properties of the List, I read I have to Override the method, but I don't want to add any complexity.

The only way I found that works fast is Actual.Equals(Expected); , but then the issue is I don't have any access to methods such as contains(); without some sort of framework.

What is the best way to quickly compare List properties? I'm open to other tools or frameworks for VisualStudio and C#.

Thanks.

Elsid
  • 243
  • 2
  • 10
  • 25

1 Answers1

1

What are you trying to test? The correctness of the SQL queries? The code that executes and returns the queries? Sql Server? Why is it you need to test thousands of results? It sounds to me like you are (ab)using xunit to run integration or QA-like testing on real data. That's not what unit testing is for.

That said, I'm guilty of doing similar things. Sometimes you really do need to test the database (the queries that is). If it is a "unit test" of the SQL queries or integration testing you should be using a much smaller set of data.

See https://stackoverflow.com/a/22173807 for comparing lists.

I think the real solution is to reduce the amount of data you are comparing and make sure you are testing what it is you really intend to test.

Community
  • 1
  • 1
Colin Young
  • 3,018
  • 1
  • 22
  • 46