StrataFrame Forum
Home
»
StrataFrame Application Framework - V1
»
Business Objects and Data Access (How do I?)
NUnit and BOs
http://forum.strataframe.net/Topic461.aspx
By Scott
-
1/20/2006
Anyone using NUnit with StrataFrame?
Any suggestion on how to test BOs?
By StrataFrame Team
-
1/23/2006
Nope, we're using Visual Studio TS for Software Developers, which has the VSTS unit testing. Most of our unit tests are very straightforward... pull in a record -> check the count -> pull in another record -> check the count -> modify a record -> check IsDirty -> Save() the BO -> check IsDirty again... nothing too spectacular. All of them have been written by hand, rather than autogenerated.
By Jason Seidell
-
11/8/2007
I got NUnit working fine with SF, however it requires a little more work to properly create the SF environment. From what I can gather NUnit does not run the code the same way as running the executable, so it needs some initialization or you will get DataSourceKey not found or problems loading and referencing SF BOs.
1) In the AppMain you need to add a new Main startup routine, I called mine TestingMain and have it at least call the SetDataSources() routine
** In AppMain ***
Public Shared Sub TestingMain()
SetDataSources()
End Sub
**************
2) Add a call to the initialization inside the NUnit startup routine.
** In the NUnit Test Fixture **
_
Public Sub InitEmployees()
' Initialize all the SF stuff
AppMain.TestingMain()
_employeesBO = New Employee_BO()
_ruleSetBO = New RuleSet_BO()
_employeesBO.FillAll()
_ruleSetBO.FillAll()
End Sub
_
Public Sub AddHours()
Dim results As New Collection()
_employeesBO.MoveFirst()
' Store all the current hours
For i As Integer = 1 To _employeesBO.Count
'_employeesBO.MoveAbsolute(i)
*****************************************
I assume if you are using locatelization or RBS then you may need to add some additional calls to the TestingMain(). I even suspect you could create TestingSetDataSources() to have the code automatically connect to a testing database when running the tests.
I hope this is a help to someone.
Jason S.
By StrataFrame Team
-
11/8/2007
Yep, you have to do that with VSTS unit tests, too. There is a ClassInitialize() method in which you have to add the DataSourceItem to the DataSources collection.
You just had to find that the hard way