Checks that mock object exists in the database, checks that it is correctly registered in the DBTD_TBL_PRETEND_OBJECT table and that it was automatically created by the DBTestDriven Framework. Report failure in any other case.
v_PretendObjectName – Name of the mock object. Supports four part object name. SYSNAME data type.
v_UserMessage – Message to report when assertion fails, NVARCHAR(MAX)
Note: If you are planning to run unit test manually, you must use DBTD_UNIT_TEST hint procedure to explicitly define a unit test procedure as the unit test.
/*Create inner procedure that will be called within outer scope*/
CREATE PROC AddNewUser
/*create primary outer procedure*/
CREATE PROC SetupDefaultUsers
EXEC AddNewUser @UserName = 'Kelly', @UserRole = 'Administrator'
EXEC AddNewUser @UserName = 'Bill', @UserRole = 'Reporting Team'
EXEC AddNewUser @UserName = 'Michael', @UserRole = 'Developer'
/*create unit test procedure*/
CREATE PROCEDURE UT_USERTESTS_AddNewUser
--make sure that this test is the part of the USERTESTS suite
EXEC DBTD_UNIT_TEST 'USERTESTS'
--create mock for inner procedure
EXEC DBTD_CREATE_MOCK_PROCEDURE 'AddNewUser', NULL, NULL, NULL
--call primary busines logic
--assert that mock procedure exist, which it should because
--we have created it in the prior statement
@v_PrependObjectName = 'AddNewUser',
@v_UserMessage = 'We have issues'
--run just one unit test alone to verify results
--note that we will explicitly use transactions
--because we run unit test outside of the DBTestDriven framework