Dan
Dan

Reputation: 11183

How to use approval tests for testing databases?

I would like to approval-test a result of a database query using classes provided by ApprovalTests.Net library. I understand how approval tests work, but could not find a single example on how to use classes from Persistence namespaces. Would appreciate some examples to get me started.

I am refactoring a complex Sql query. I need to make sure that the new version of the query is returning a same resultset after the refactoring. I think I can accomplish it like this:

DataSet dataSet = new DataSet();
dataSet.Fill(adapter, connection);
StringWriter sw = new StringWriter();
dataSet.WriteXml(sw);
string result = sw.ToString();
Approvals.Verify(result);

But I think there is a better way to do it using classes from Persistence namespace without explicit conversion of Dataset to xml string.

Upvotes: 1

Views: 783

Answers (1)

Lynn Langit
Lynn Langit

Reputation: 4060

Chris made a screencast about the ILoader pattern with ApprovalTests.

Upvotes: 2

Related Questions