Skip to content

Commit da6191d

Browse files
committed
Create TSQL script for test case: one wrong row
1 parent 85b1267 commit da6191d

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
-------------------------------------------------------------------------
2+
-- Demo: SQL Server CI/CD -
3+
-- -
4+
-- Script: Test case: try to insert one wrong row -
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 one wrong row]
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 one wrong rows with SafetyStockLevel lower than 10
24+
*/
25+
INSERT INTO Production.Product
26+
(
27+
[Name]
28+
,ProductNumber
29+
,MakeFlag
30+
,FinishedGoodsFlag
31+
,SafetyStockLevel
32+
,ReorderPoint
33+
,StandardCost
34+
,ListPrice
35+
,DaysToManufacture
36+
,SellStartDate
37+
,rowguid
38+
,ModifiedDate
39+
)
40+
VALUES
41+
(
42+
N'Carbon Bar 1'
43+
,N'CB-0001'
44+
,0
45+
,0
46+
,9 /* SafetyStockLevel */
47+
,750
48+
,0.0000
49+
,78.0000
50+
,0
51+
,GETDATE()
52+
,NEWID()
53+
,GETDATE()
54+
);
55+
56+
/*
57+
Assert
58+
*/
59+
IF NOT EXISTS (SELECT _id_ FROM Production.usp_Raiserror_SafetyStockLevel_SpyProcedureLog)
60+
EXEC tSQLt.Fail
61+
@Message0 = 'Production.usp_Raiserror_SafetyStockLevel_SpyProcedureLog is empty! usp_Raiserror_SafetyStockLevel has not been called!';
62+
END;
63+
GO
64+
65+
EXEC tSQLt.Run 'UnitTestTRProductSafetyStockLevel.[test try to insert one wrong row]';
66+
GO

0 commit comments

Comments
 (0)