views:

14

answers:

0

I have a UDF that accepts two dates and minute interval, does some date math, then spits out the difference between date1 + interval and date2, honoring business hours. I just found out about VS DB project type and am writing some unit tests. As far as I can tell, I can only set up one context per test, even though multiple Test Conditions are allowed. This is what I'd like to do:

DECLARE @RC AS DATETIME, @date1 AS DATETIME, @date2 AS DATETIME, @interval AS INT;

SELECT @RC = NULL,
       @date1 = '2010-8-10 08:00:00:000',
       @date2 = '2010-8-10 08:00:00:000',
       @interval = 240;

SELECT @RC = [dbo].[udf_DateDiffBusinessHours](@date1, @date2, @interval);

SELECT DATEDIFF(n, 0, @RC) AS RC;

SELECT @RC = NULL,
       @date1 = '2010-8-10 08:00:00:000',
       @date2 = '2010-8-10 10:00:00:000',
       @interval = 240;
       y
SELECT @RC = [dbo].[udf_DateDiffBusinessHours](@date1, @date2, @interval);

SELECT DATEDIFF(n, 0, @RC) AS RC;

If I run the tests as they are now, both are scalar value tests, the first test fails because it's comparing its expected value with the result from the second query. Is there any way to make this work?

Not a popular topic, eh?