Skip to content

Commit e6c0dd9

Browse files
committed
Create TSQL script for test case: multiple ordered rows
1 parent bedb9da commit e6c0dd9

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
-------------------------------------------------------------------------
2+
-- Demo: SQL Server CI/CD -
3+
-- -
4+
-- Script: Test case: try to insert multiple rows ordered -
5+
-- Author: Sergio Govoni -
6+
-- Notes: -- -
7+
-------------------------------------------------------------------------
8+
9+
SET QUOTED_IDENTIFIER ON;
10+
GO
11+
12+
CREATE OR ALTER PROCEDURE UnitTestTRProductSafetyStockLevel.[test try to insert multiple rows ordered]
13+
AS
14+
BEGIN
15+
/*
16+
Arrange:
17+
Spy the procedure Production.usp_Raiserror_SafetyStockLevel
18+
*/
19+
EXEC tSQLt.SpyProcedure 'Production.usp_Raiserror_SafetyStockLevel';
20+
21+
/*
22+
Act:
23+
Try to insert multiple rows
24+
The first product has a right value for SafetyStockLevel column,
25+
whereas the value in second one is wrong
26+
*/
27+
INSERT INTO Production.Product
28+
(
29+
[Name]
30+
,ProductNumber
31+
,MakeFlag
32+
,FinishedGoodsFlag
33+
,SafetyStockLevel
34+
,ReorderPoint
35+
,StandardCost
36+
,ListPrice
37+
,DaysToManufacture
38+
,SellStartDate
39+
,rowguid
40+
,ModifiedDate
41+
)
42+
VALUES
43+
(
44+
N'Carbon Bar 1'
45+
,N'CB-0001'
46+
,0
47+
,0
48+
,15 /* SafetyStockLevel */
49+
,750
50+
,0.0000
51+
,78.0000
52+
,0
53+
,GETDATE()
54+
,NEWID()
55+
,GETDATE()
56+
),
57+
(
58+
N'Carbon Bar 3'
59+
,N'CB-0003'
60+
,0
61+
,0
62+
,3 /* SafetyStockLevel */
63+
,750
64+
,0.0000
65+
,78.0000
66+
,0
67+
,GETDATE()
68+
,NEWID()
69+
,GETDATE()
70+
);
71+
72+
/*
73+
Assert
74+
*/
75+
IF NOT EXISTS (SELECT _id_ FROM Production.usp_Raiserror_SafetyStockLevel_SpyProcedureLog)
76+
EXEC tSQLt.Fail
77+
@Message0 = 'Production.usp_Raiserror_SafetyStockLevel_SpyProcedureLog is empty! usp_Raiserror_SafetyStockLevel has not been called!';
78+
79+
-- Optimized assert command, to be evaluated
80+
--EXEC tSQLt.AssertEmptyTable @TableName = 'Production.usp_Raiserror_SafetyStockLevel_SpyProcedureLog';
81+
END;
82+
GO
83+
84+
EXEC tSQLt.Run 'UnitTestTRProductSafetyStockLevel.[test try to insert multiple rows ordered]';
85+
GO

0 commit comments

Comments
 (0)