Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more tests
  • Loading branch information
lizbaron committed Oct 3, 2021
commit ab2b8276de114215839ee44621ae4f9051c6614b
2 changes: 1 addition & 1 deletion VSOnlySolution/Tests/Run_tSQLt.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EXEC tSQLt.RunAll;
/*
EXEC tSQLt.Run 'SomeRandomTests';
EXEC tSQLt.Run 'dbo_ExampleProcedureTests';
--*/
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,44 @@ BEGIN

EXEC tSQLt.AssertEqualsTable @Expected = '#Expected', @Actual = '#Actual';
END;
GO
GO
CREATE PROCEDURE [dbo_ExampleProcedureTests].[test returns the value of the single row as AverageAmount if the table has only one row]
AS
BEGIN
EXEC tSQLt.FakeTable 'dbo.ExampleTable';
INSERT INTO dbo.ExampleTable (Amount) VALUES (12.12);

CREATE TABLE #Actual(
AverageAmount DECIMAL(13,3)
);

INSERT INTO #Actual
EXEC dbo.ExampleProcedure;

SELECT TOP(0)A.* INTO #Expected FROM #Actual A RIGHT JOIN #Actual X ON 1=0;

INSERT INTO #Expected VALUES(12.12);

EXEC tSQLt.AssertEqualsTable @Expected = '#Expected', @Actual = '#Actual';
END;
GO
CREATE PROCEDURE [dbo_ExampleProcedureTests].[test returns the correct AverageAmount if the table has multiple rows]
AS
BEGIN
EXEC tSQLt.FakeTable 'dbo.ExampleTable';
INSERT INTO dbo.ExampleTable (Amount) VALUES (100), (200), (300);

CREATE TABLE #Actual(
AverageAmount DECIMAL(13,3)
);

INSERT INTO #Actual
EXEC dbo.ExampleProcedure;

SELECT TOP(0)A.* INTO #Expected FROM #Actual A RIGHT JOIN #Actual X ON 1=0;

INSERT INTO #Expected VALUES(200);

EXEC tSQLt.AssertEqualsTable @Expected = '#Expected', @Actual = '#Actual';
END;
GO