I imported my SQL Server 2008 DB script and created a new VS 2010 project to create Unit Testing for the database. It has built in functionality for checking return row count and scalar variables
What I need to know is how I can clear the entire database prior to running the procedures because it will check the new inserted row but requires I tell it a row# to check.
Here is the code for a unit test calling a stored proc to insert an addres:
-- database unit test for dbo.spInsertAddress
DECLARE @RC AS INT, @Street AS VARCHAR (60), @City AS VARCHAR (50), @State AS CHAR (20), @Zip AS VARCHAR (10), @Intersection1 AS VARCHAR (60), @Intersection2 AS VARCHAR (60), @AddressID AS INT;
SELECT @RC = 0,
@Street = 'StreetName',
@City = NULL,
@State = NULL,
@Zip = NULL,
@Intersection1 = NULL,
@Intersection2 = NULL;
EXECUTE @RC = [dbo].[spInsertAddress] @Street, @City, @State, @Zip, @Intersection1, @Intersection2, @AddressID OUTPUT;
--SELECT @RC AS RC,
-- @AddressID AS AddressID;
SELECT * FROM Address;
Here is an image of the VS unit testing:
To reiterate the question how do I clear the database or remove whatever was inserted AFTER the procedure runs?
Also for others interested in Unit Testing a DB via VS here is a link: Create Database Unit Tests for Functions, Triggers, and Stored Procedures