Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for checking the referencial integrity of a table when defined on one or more columns #352

Closed
Seddryck opened this issue Jan 25, 2018 · 3 comments

Comments

@Seddryck
Copy link
Owner

Seddryck commented Jan 25, 2018

It should be possible to define a query and check that a set of the returned columns contain values provided by another query.

<system-under-test>
  <result-set>
    <query>select field1, field2, field3 from myTable</select>
  </result-set>
</system-under-test>
<assert>
  <reference-exists>
    <column-mapping child="#0" parent="#0"/>
    <column-mapping child="#2" parent="#1" />
    <result-set>
       <query> select foo, bar from myOtherTable </query>
    </result-set>
  </reference-exists>
</assert>
@Seddryck Seddryck changed the title Add support foor checking the integrity of one or more columns Add support for checking the referencial integrity of a table when defined on one or more columns Jan 25, 2018
@FuegoArtificial
Copy link

FuegoArtificial commented Jan 27, 2018

Hi @Seddryck,

the solution which I'm using for it is the following template, provided you have the test case data saved somewhere else.
Perhaps it helps.

<test name="All values of field '$SourceIdField$' of table '$SourceIdFieldTable$' are referentially integer with field '$ReferenceIdField$' of table '$ReferenceIdFieldTable$'.">   		
	$if(IgnoreReason)$<ignore>$IgnoreReason$</ignore>$endif$  
	<category>Referential Integrity</category>
	<system-under-test>
		<execution>
			<query connectionString="@myDB">
				<![CDATA[SELECT DISTINCT $SourceIdField$ FROM $SourceIdFieldTable$
				EXCEPT
				SELECT $ReferenceIdField$ FROM $ReferenceIdFieldTable$]]>
			</query>
		</execution>
	</system-under-test>
	<assert>
		<equalTo>
			<query connectionString="@myDB">
				<![CDATA[SELECT DISTINCT $SourceIdField$ FROM $SourceIdFieldTable$ WHERE 0 = 1]]>
			</query>
		</equalTo>
	</assert>
</test>

About the feature request #349: I have to refine the template first to provide a reasonable template to the public.

Cheers

@Seddryck
Copy link
Owner Author

@Seddryck
Copy link
Owner Author

Not really happy with the current naming.

It should be lookup-exist, parent should be renamed reference and child should candidate. column-mapping should also be embedded in a join after being renamed mapping. A shortcut should be added to mapping letting the user expressed that the two columns used during the equijoin have the same position or name (using).

And if several rows in the reference table validate the lookup … it should not be a problem.

Seddryck pushed a commit that referenced this issue Aug 25, 2018
# Conflicts:
#	NBi.Core/NBi.Core.csproj
#	NBi.NUnit/Builder/ResultSetLookupExistsBuilder.cs
#	NBi.Testing/NBi.Testing.csproj
@Seddryck Seddryck added this to the v1.19 milestone Nov 1, 2018
@Seddryck Seddryck closed this as completed Nov 1, 2018
Seddryck pushed a commit that referenced this issue Jan 31, 2019
…verse feature #413 to new tab ... lookup-matches, reverse-lookup and lookup-exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants