Skip to content

Commit

Permalink
Fix SRD0016 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cagrin committed Mar 14, 2024
1 parent abb96fe commit cdd3902
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 9 deletions.
1 change: 0 additions & 1 deletion latest/SqlCodeAnalysisRules.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<CodeAnalysisRules>-SqlServer.Rules.SRD0009; $(CodeAnalysisRules)</CodeAnalysisRules>
<CodeAnalysisRules>-SqlServer.Rules.SRD0013; $(CodeAnalysisRules)</CodeAnalysisRules>
<CodeAnalysisRules>-SqlServer.Rules.SRD0015; $(CodeAnalysisRules)</CodeAnalysisRules>
<CodeAnalysisRules>-SqlServer.Rules.SRD0016; $(CodeAnalysisRules)</CodeAnalysisRules>
<CodeAnalysisRules>-SqlServer.Rules.SRD0017; $(CodeAnalysisRules)</CodeAnalysisRules>
<CodeAnalysisRules>-SqlServer.Rules.SRD0024; $(CodeAnalysisRules)</CodeAnalysisRules>
<CodeAnalysisRules>-SqlServer.Rules.SRD0026; $(CodeAnalysisRules)</CodeAnalysisRules>
Expand Down
13 changes: 13 additions & 0 deletions latest/tSQLt.Edge.Tests/InterfaceTests/Test_AssertEqualsTable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ BEGIN
END;
GO

CREATE PROCEDURE Test_AssertEqualsTable.Test_ErrorMessage_FailMsg
AS
BEGIN
CREATE TABLE dbo.TestTable1 (Column1 INT);
CREATE TABLE dbo.TestTable2 (Column1 INT);
INSERT INTO dbo.TestTable1 (Column1) VALUES (1);

EXEC tSQLt.ExpectException 'Error message. Fail message. tSQLt.AssertEqualsTable failed. Expected:<dbo.TestTable1> has different rowset than Actual:<dbo.TestTable2>.';

EXEC tSQLt.AssertEqualsTable 'dbo.TestTable1', 'dbo.TestTable2', 'Error message.', 'Fail message.';
END;
GO

CREATE PROCEDURE Test_AssertEqualsTable.Test_SecondTableIsNotEmpty
AS
BEGIN
Expand Down
2 changes: 1 addition & 1 deletion latest/tSQLt.Edge.Tests/InterfaceTests/Test_DropClass.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GO
CREATE PROCEDURE Test_DropClass.Test_IsUnsupported
AS
BEGIN
EXEC tSQLt.ExpectException 'tSQLt.DropClass is not supported.'
EXEC tSQLt.ExpectException 'tSQLt.DropClass of TestClass1 is not supported.'

EXEC tSQLt.DropClass 'TestClass1';
END;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GO
CREATE PROCEDURE Test_NewTestClass.Test_IsUnsupported
AS
BEGIN
EXEC tSQLt.ExpectException 'tSQLt.NewTestClass is not supported. Use CREATE SCHEMA ''ClassName''.'
EXEC tSQLt.ExpectException 'tSQLt.NewTestClass of TestClass1 is not supported.'

EXEC tSQLt.NewTestClass 'TestClass1';
END;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GO
CREATE PROCEDURE Test_RenameClass.Test_IsUnsupported
AS
BEGIN
EXEC tSQLt.ExpectException 'tSQLt.RenameClass is not supported.'
EXEC tSQLt.ExpectException 'tSQLt.RenameClass of TestClass1 to NewTestClass1 is not supported.'

EXEC tSQLt.RenameClass 'TestClass1', 'NewTestClass1';
END;
Expand Down
9 changes: 9 additions & 0 deletions latest/tSQLt.Edge.Tests/InterfaceTests/Test_Run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ BEGIN
EXEC tSQLt.Fail 'dbo.NewTable should not exists.';
END
END;
GO

CREATE PROCEDURE Test_Run.Test_ResultFormatter_IsUnsupported
AS
BEGIN
EXEC tSQLt.ExpectException 'tSQLt.Run with @TestResultFormatter is not supported.'

EXEC tSQLt.Run '[Test_Run].[Test_CreateNewTable]', @TestResultFormatter = 'ResultFormatter';
END;
GO
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ BEGIN
DECLARE @Failed NVARCHAR(MAX) = CONCAT_WS
(
' ',
NULLIF(@FailMsg, 'Unexpected/missing resultset rows!'),
'tSQLt.AssertEqualsTable failed.',
CONCAT('Expected:<', ISNULL(@Expected, '(null)'), '>'),
'has different rowset than',
CONCAT('Actual:<', ISNULL(@Actual, '(null)'), '>.')
);
EXEC tSQLt.Fail @Message, @Failed;
END

SET @FailMsg = NULL
END;
GO
2 changes: 1 addition & 1 deletion latest/tSQLt.Edge/Internal/tSQLt.Internal_DropClass.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ CREATE PROCEDURE tSQLt.Internal_DropClass
@ClassName NVARCHAR(MAX)
AS
BEGIN
EXEC tSQLt.Fail 'tSQLt.DropClass is not supported.';
EXEC tSQLt.Fail 'tSQLt.DropClass of', @ClassName, 'is not supported.';
END;
GO
2 changes: 1 addition & 1 deletion latest/tSQLt.Edge/Internal/tSQLt.Internal_NewTestClass.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ CREATE PROCEDURE tSQLt.Internal_NewTestClass
@ClassName NVARCHAR(MAX)
AS
BEGIN
EXEC tSQLt.Fail 'tSQLt.NewTestClass is not supported. Use CREATE SCHEMA ''ClassName''.';
EXEC tSQLt.Fail 'tSQLt.NewTestClass of', @ClassName, 'is not supported.';
END;
GO
2 changes: 1 addition & 1 deletion latest/tSQLt.Edge/Internal/tSQLt.Internal_RenameClass.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ CREATE PROCEDURE tSQLt.Internal_RenameClass
@NewSchemaName NVARCHAR(MAX)
AS
BEGIN
EXEC tSQLt.Fail 'tSQLt.RenameClass is not supported.';
EXEC tSQLt.Fail 'tSQLt.RenameClass of', @SchemaName, 'to', @NewSchemaName, 'is not supported.';
END;
GO
5 changes: 5 additions & 0 deletions latest/tSQLt.Edge/Internal/tSQLt.Internal_Run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ CREATE PROCEDURE tSQLt.Internal_Run
@TestResultFormatter NVARCHAR(MAX) = NULL
AS
BEGIN
IF @TestResultFormatter IS NOT NULL
BEGIN
EXEC tSQLt.Fail 'tSQLt.Run with @TestResultFormatter is not supported.';
END

DELETE FROM tSQLt.TestResult;

DECLARE @TestNames tSQLt.Private_TestNamesType;
Expand Down
4 changes: 2 additions & 2 deletions latest/tSQLt.Edge/Private/tSQLt.Private_Run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BEGIN
IF @TranCounter = 0
BEGIN TRANSACTION;
ELSE
SAVE TRANSACTION @TestName;
SAVE TRANSACTION @TranName;

BEGIN TRY
EXEC @TestName;
Expand All @@ -33,6 +33,6 @@ BEGIN
ROLLBACK TRANSACTION;
ELSE
IF XACT_STATE() <> -1
ROLLBACK TRANSACTION @TestName;
ROLLBACK TRANSACTION @TranName;
END;
GO
1 change: 1 addition & 0 deletions legacy/tSQLt.Unoriginal.Tests/Post-Deployment/Debug.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ END;

-- Failure
EXEC ('DROP PROCEDURE [Test_AssertEqualsTable].[Test_ErrorMessage]');
EXEC ('DROP PROCEDURE [Test_AssertEqualsTable].[Test_ErrorMessage_FailMsg]');
EXEC ('DROP PROCEDURE [Test_AssertEqualsTable].[Test_FirstTableHasTwinRows]');
EXEC ('DROP PROCEDURE [Test_AssertEqualsTable].[Test_FirstTableIsNotEmpty]');
EXEC ('DROP PROCEDURE [Test_AssertEqualsTable].[Test_FloatLossOfPrecision]');
Expand Down

0 comments on commit cdd3902

Please sign in to comment.