Skip to content

Pull Request from work20231116190247 to main20231116190247 #4

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

Open
wants to merge 2 commits into
base: main20231116190247
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Demo/dbo.GetDiscount.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ CREATE FUNCTION dbo.GetDiscount(@amount DECIMAL(13,2))
RETURNS TABLE
AS
RETURN
SELECT 0 Discount;
SELECT CASE WHEN @amount>=50 THEN @amount*.1 ELSE 0 END Discount;
18 changes: 18 additions & 0 deletions Tests/GetDiscountTests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,21 @@ BEGIN
EXEC tSQLt.AssertEqualsTable '#expected','#actual';
END;
GO
CREATE PROCEDURE GetDiscountTests.[test 10% discount if amount greater 50]
AS
BEGIN
SELECT Discount INTO #actual FROM dbo.GetDiscount(51.00);
SELECT TOP(0) A.* INTO #expected FROM #actual X LEFT JOIN #actual A ON 1=0;
INSERT INTO #expected VALUES(5.1);
EXEC tSQLt.AssertEqualsTable '#expected','#actual';
END;
GO
CREATE PROCEDURE GetDiscountTests.[test 10% discount if amount equal 50]
AS
BEGIN
SELECT Discount INTO #actual FROM dbo.GetDiscount(50.00);
SELECT TOP(0) A.* INTO #expected FROM #actual X LEFT JOIN #actual A ON 1=0;
INSERT INTO #expected VALUES(5.0);
EXEC tSQLt.AssertEqualsTable '#expected','#actual';
END;
GO