-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGetDiscountTests.sql
More file actions
40 lines (40 loc) · 1.33 KB
/
GetDiscountTests.sql
File metadata and controls
40 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*----------------------------------------------
-- ** Requirements **
----------------------------------------------
-- For All Orders:
-- If Order Total is $0 to $50: No Discount
-- If Order Total is $50 to $50K: 10% Discount
-----------------------------------------------*/
/*--
EXEC tSQLt.DropClass 'GetDiscountTests';
--*/
GO
CREATE SCHEMA GetDiscountTests AUTHORIZATION [tSQLt.TestClass];
GO
CREATE PROCEDURE GetDiscountTests.[test no discount if amount smaller 50]
AS
BEGIN
SELECT Discount INTO #actual FROM dbo.GetDiscount(49.00);
SELECT TOP(0) A.* INTO #expected FROM #actual X LEFT JOIN #actual A ON 1=0;
INSERT INTO #expected VALUES(0);
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