{"id":18937423,"url":"https://github.com/verifytests/verify.sqlserver","last_synced_at":"2026-04-25T02:11:30.710Z","repository":{"id":40284080,"uuid":"232479290","full_name":"VerifyTests/Verify.SqlServer","owner":"VerifyTests","description":"Extends Verify to allow verification of SqlServer bits.","archived":false,"fork":false,"pushed_at":"2025-09-05T23:33:48.000Z","size":920,"stargazers_count":18,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-06T01:18:04.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VerifyTests.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.txt","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"VerifyTests"}},"created_at":"2020-01-08T04:41:29.000Z","updated_at":"2025-09-05T23:31:57.000Z","dependencies_parsed_at":"2024-01-10T03:29:47.487Z","dependency_job_id":"4a7b9be7-bcdc-403e-8796-084584c8dcc8","html_url":"https://github.com/VerifyTests/Verify.SqlServer","commit_stats":{"total_commits":778,"total_committers":4,"mean_commits":194.5,"dds":0.4974293059125964,"last_synced_commit":"dfb9753e0a20aa38d465b2d01ab5e0f11b854fa9"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/VerifyTests/Verify.SqlServer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.SqlServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.SqlServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.SqlServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.SqlServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VerifyTests","download_url":"https://codeload.github.com/VerifyTests/Verify.SqlServer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.SqlServer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274187201,"owners_count":25237741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T12:11:07.023Z","updated_at":"2026-04-25T02:11:30.703Z","avatar_url":"https://github.com/VerifyTests.png","language":"C#","funding_links":["https://github.com/sponsors/VerifyTests"],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"/src/icon.png\" height=\"30px\"\u003e Verify.SqlServer\n\n[![Discussions](https://img.shields.io/badge/Verify-Discussions-yellow?svg=true\u0026label=)](https://github.com/orgs/VerifyTests/discussions)\n[![Build status](https://img.shields.io/appveyor/build/SimonCropp/verify-sqlserver)](https://ci.appveyor.com/project/SimonCropp/verify-sqlserver)\n[![NuGet Status](https://img.shields.io/nuget/v/Verify.SqlServer.svg)](https://www.nuget.org/packages/Verify.SqlServer/)\n\nExtends [Verify](https://github.com/VerifyTests/Verify) to allow verification of SqlServer bits.\u003c!-- singleLineInclude: intro. path: /docs/intro.include.md --\u003e\n\n**See [Milestones](../../milestones?state=closed) for release notes.**\n\n\n## Sponsors\n\n\n### Entity Framework Extensions\u003c!-- include: sponsors. path: /docs/sponsors.include.md --\u003e\n\n[Entity Framework Extensions](https://entityframework-extensions.net/?utm_source=simoncropp\u0026utm_medium=Verify.SqlServer) is a major sponsor and is proud to contribute to the development this project.\n\n[![Entity Framework Extensions](https://raw.githubusercontent.com/VerifyTests/Verify.SqlServer/refs/heads/main/docs/zzz.png)](https://entityframework-extensions.net/?utm_source=simoncropp\u0026utm_medium=Verify.SqlServer)\n\n### Developed using JetBrains IDEs\n\n[![JetBrains logo.](https://raw.githubusercontent.com/VerifyTests/Verify.SqlServer/main/docs/jetbrains.png)](https://jb.gg/OpenSourceSupport)\u003c!-- endInclude --\u003e\n\n\n## NuGet\n\n * https://nuget.org/packages/Verify.SqlServer\n\n\n## Usage\n\n\u003c!-- snippet: Enable --\u003e\n\u003ca id='snippet-Enable'\u003e\u003c/a\u003e\n```cs\n[ModuleInitializer]\npublic static void Init() =\u003e\n    VerifySqlServer.Initialize();\n```\n\u003csup\u003e\u003ca href='/src/Tests/ModuleInit.cs#L3-L9' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Enable' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### SqlServer Schema\n\nThis test:\n\n\u003c!-- snippet: SqlServerSchema --\u003e\n\u003ca id='snippet-SqlServerSchema'\u003e\u003c/a\u003e\n```cs\nawait Verify(connection);\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L317-L321' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-SqlServerSchema' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nWill result in the following verified file:\n\n\u003cpre\u003e\n\n\u003c!-- emptyInclude: Tests.Schema.verified.md --\u003e\n\u003c/pre\u003e\n\n#### Object types to include\n\n\u003c!-- snippet: SchemaInclude --\u003e\n\u003ca id='snippet-SchemaInclude'\u003e\u003c/a\u003e\n```cs\nawait Verify(connection)\n    // include only tables and views\n    .SchemaIncludes(DbObjects.Tables | DbObjects.Views);\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L683-L689' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-SchemaInclude' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nAvailable values:\n\n\u003c!-- snippet: DbObjects.cs --\u003e\n\u003ca id='snippet-DbObjects.cs'\u003e\u003c/a\u003e\n```cs\nnamespace VerifyTests.SqlServer;\n\n[Flags]\npublic enum DbObjects\n{\n    StoredProcedures = 1,\n    Synonyms = 2,\n    Tables = 4,\n    UserDefinedFunctions = 8,\n    Views = 16,\n    All = StoredProcedures | Synonyms | Tables | UserDefinedFunctions | Views\n}\n```\n\u003csup\u003e\u003ca href='/src/Verify.SqlServer/SchemaValidation/DbObjects.cs#L1-L12' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-DbObjects.cs' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n#### Filtering\n\nObjects can be dynamically filtered:\n\n\u003c!-- snippet: SchemaFilter --\u003e\n\u003ca id='snippet-SchemaFilter'\u003e\u003c/a\u003e\n```cs\nawait Verify(connection)\n    // include tables \u0026 views, or named MyTrigger\n    .SchemaFilter(\n        _ =\u003e _ is TableViewBase ||\n             _.Name == \"MyTrigger\");\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L708-L716' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-SchemaFilter' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n\n### Recording\n\nRecording allows all commands executed to be captured and then (optionally) verified.\n\nCall `SqlRecording.StartRecording()`:\n\n\u003c!-- snippet: Recording --\u003e\n\u003ca id='snippet-Recording'\u003e\u003c/a\u003e\n```cs\nawait using var connection = new SqlConnection(connectionString);\nawait connection.OpenAsync();\nRecording.Start();\nawait using var command = connection.CreateCommand();\ncommand.CommandText = \"select Value from MyTable\";\nvar value = await command.ExecuteScalarAsync();\nawait Verify(value!);\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L492-L502' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Recording' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nWill result in the following verified file:\n\n\u003c!-- snippet: Tests.RecordingUsage.verified.txt --\u003e\n\u003ca id='snippet-Tests.RecordingUsage.verified.txt'\u003e\u003c/a\u003e\n```txt\n{\n  target: 42,\n  sql: {\n    Text:\nselect Value\nfrom   MyTable,\n    HasTransaction: false\n  }\n}\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.RecordingUsage.verified.txt#L1-L9' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Tests.RecordingUsage.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\nSql entries can be explicitly read using `SqlRecording.FinishRecording`, optionally filtered, and passed to Verify:\n\n\u003c!-- snippet: RecordingSpecific --\u003e\n\u003ca id='snippet-RecordingSpecific'\u003e\u003c/a\u003e\n```cs\nawait using var connection = new SqlConnection(connectionString);\nawait connection.OpenAsync();\nRecording.Start();\nawait using var command = connection.CreateCommand();\ncommand.CommandText = \"select Value from MyTable\";\nvar value = await command.ExecuteScalarAsync();\n\nawait using var errorCommand = connection.CreateCommand();\nerrorCommand.CommandText = \"select Value from BadTable\";\ntry\n{\n    await errorCommand.ExecuteScalarAsync();\n}\ncatch\n{\n}\n\nvar entries = Recording\n    .Stop()\n    .Select(_ =\u003e _.Data);\n//Optionally filter results\nawait Verify(\n    new\n    {\n        value,\n        sqlEntries = entries\n    });\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L569-L599' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-RecordingSpecific' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n#### Interpreting recording results\n\nRecording results can be interpreted in a a variety of ways:\n\n\u003c!-- snippet: RecordingReadingResults --\u003e\n\u003ca id='snippet-RecordingReadingResults'\u003e\u003c/a\u003e\n```cs\nvar entries = Recording.Stop();\n\n// all sql entries via key\nvar sqlEntries = entries\n    .Where(_ =\u003e _.Name == \"sql\")\n    .Select(_ =\u003e _.Data);\n\n// successful Commands via Type\nvar sqlCommandsViaType = entries\n    .Select(_ =\u003e _.Data)\n    .OfType\u003cSqlCommand\u003e();\n\n// failed Commands via Type\nvar sqlErrorsViaType = entries\n    .Select(_ =\u003e _.Data)\n    .OfType\u003cErrorEntry\u003e();\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L625-L644' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-RecordingReadingResults' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Icon\n\n[Database](https://thenounproject.com/term/database/310841/) designed by [Creative Stall](https://thenounproject.com/creativestall/) from [The Noun Project](https://thenounproject.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverifytests%2Fverify.sqlserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fverifytests%2Fverify.sqlserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverifytests%2Fverify.sqlserver/lists"}