Home > Archive > MS SQL Server Notification Services > April 2005 > Unit Testing .NET Event Provider?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Unit Testing .NET Event Provider?
MarkSW

2005-04-01, 8:03 pm

Does anyone have any ideas on setting up a unit testing application to test
an EP assembly independently of running a full NS application end to end and
seeing what comes out in the emails? Obviously, the EP can log to file to
aid in debugging, but what I mean is a structured, reusable, independent set
of tests in another assembly, a la an NUnit project. This works great for a
standalone class library scenario but I can't see a way to do it in a useful,
meaningful way for an EP. I understand that handling dependencies in general
are an issue with unit testing, but I'm not yet experienced in how to work
around them. Are mock objects the anwer here? Has anyone done this?
Joe Webb

2005-04-04, 8:04 pm

You're right, test the application is an almost all or nothing scenario
in practice. You can disable all components except the event provider
and then check the EventBatches and Events tables.


HTH...
Joe Webb
SQL Server MVP

~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/t...il/-/0972688811




MarkSW wrote:
> Does anyone have any ideas on setting up a unit testing application to test
> an EP assembly independently of running a full NS application end to end and
> seeing what comes out in the emails? Obviously, the EP can log to file to
> aid in debugging, but what I mean is a structured, reusable, independent set
> of tests in another assembly, a la an NUnit project. This works great for a
> standalone class library scenario but I can't see a way to do it in a useful,
> meaningful way for an EP. I understand that handling dependencies in general
> are an issue with unit testing, but I'm not yet experienced in how to work
> around them. Are mock objects the anwer here? Has anyone done this?

MarkSW

2005-04-05, 8:05 pm

I've done some more analysis and preliminary design and I actually have
something more "unit test like," at least on paper.

Highlights are:
- Create an NUnit project that reads in a config file in its SetUp().
- Config file has instance name, application name, whether the service uses
Events or a ScheduledRule to generate notifications, and a block of
name/value pairs for all the fields in the Event/Subscription schema.
- Depending on type of service (Event/Scheduled) a
Test_GenerateNotific
ation() test method calls the NSEvent* SPs to submit the
event or NSExecuteRuleFiring
- Method then calls NSSnapshotEvents or NSDiagnosticSubscrip
tions to verify
the result
- Batch file attached to the project as a pre-build event disables (at
least) the Generator so programmatic submissions work

***CAVEAT*** I haven't actually built this, so I don't know if it will work
(but it sounds nice).

But if it does, it has the advantage of letting other developers (which is
where I'm at right now, building an in-house NS framework for the shop) just
deploy the Nunit assembly and config file to their machine, set the values in
the config file for their service, and run the assembly tests from NUnit GUI.
They won't have to write their own unit tests.

But this is not a trivial amount of work, and because it won't work unless
the SP calls can point to a valid, built NS application, so I'm not sure how
much value it adds. All I can see is that it lets you do something that
"feels more like a unit test." But the only dependency you are actually
isolated from is the mail server/waiting for the email. This is something,
but it will only pay off if the developer needs to run a lot of tests and the
waiting a few minutes each time will really matter. Of course it has the
added usual advantage of having a separate, documented unit testing artifact
....


"MarkSW" wrote:

> Does anyone have any ideas on setting up a unit testing application to test
> an EP assembly independently of running a full NS application end to end and
> seeing what comes out in the emails? Obviously, the EP can log to file to
> aid in debugging, but what I mean is a structured, reusable, independent set
> of tests in another assembly, a la an NUnit project. This works great for a
> standalone class library scenario but I can't see a way to do it in a useful,
> meaningful way for an EP. I understand that handling dependencies in general
> are an issue with unit testing, but I'm not yet experienced in how to work
> around them. Are mock objects the anwer here? Has anyone done this?

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com