18 Answers, 1 is accepted
There are no mock objects for unit testing at the moment. We just try to clean the database content in the testcase setup method and additional after the tests in the cleanup.
All the best,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Please check this topic from our documentation and tell us what you think of the content there:
http://www.telerik.com/help/openaccess-orm/openaccess-tasks-howto-using-openaccess-with-test-frameworks.html.
Hope this helps.
All the best,
Dimitar Kapitanov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

Well there are supporters of both approaches. Let me explain why I prefer using test databases against database mocks: by using a test database, you open up the possibility that problems could be caused at the database itself or along the communication path (network, etc) between the DAL and database. Mocking eliminates those possibilities. And in the end mocks hinder the unit tests because you are not taking into account a series of real world problems that usually have impact on your behavior. I think that it would be much more productive to have those things sorted out in the testing phase. From my perspective if you test only BOs using mocks of the DAL and everything is OK, and then in the real case situation you hit a showstopper because of the DAL, this puts you in the same awful situation. Of course that is my opinion, and I do not believe that we can put a statement what best practices are, or are not. Everyone should decide based on the context of the task is my opinion.
All the best,
Dimitar Kapitanov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.


It was a really nice post. I enjoyed reading it.
Greetings,
Dimitar Kapitanov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

I've tried using the testing frame work in class "PersonserviceTestsWithoutMocking" as discussed in the following article http://www.reversealchemy.net/2009/03/17/exploring-telerik-openaccess-unit-testing-your-business-logic-using-rhino-mocks/, However the code looks it very old as it uses ObjectScopeProvider1 and I can't find that object in the latest Free Edition of Open Access ORM.
I then read this article and applied the code changes to my model: http://www.telerik.com/community/forums/orm/development/where-is-objectscopeprovider1.aspx, This seemed to work however how do I access the entities within my model via the scope variable?In PersonserviceTestsWithoutMocking example they wrote the following:
Person sparrow = scope.Extent().SingleOrDefault( p => p.LastName.Equals( "Sparrow" ) );
However when I write the same piece of code it can't find the type Person (or in my case object Security which is in my model).
Any suggestions would be great


We are currently offering unit testing examples for many of our OpenAccess SDK sample projects. You can download the SDK here and use the Open Test Solution button in order to access the sample together with its unit tests.
Let us know if those samples do not fully cover the topic or you have more specific questions on unit testing.
Ivailo
the Telerik team

Thanks for getting back to me. I've looked at the SDK and opened up the test solutions but all the tests I've looked at test the service or Mock the DAL level. What I want to do is test the actual ORM. So if I have an entity called Car I want to create a test to add, test to update and test to delete it and verify that the ORM can perform these operations. When I run the test it runs it in a transaction statement so that once the tests passes or fails it roll-backs the changes. Something like "PersonserviceTestsWithoutMocking" as discussed in the following article http://www.reversealchemy.net/2009/03/17/exploring-telerik-openaccess-unit-testing-your-business-logic-using-rhino-mocks/
Can someone point me in the right direction?
Regards
you can always "commit" your changes with a context.Flush(). This way you will be able to see the actual changes in the database thus knowing that everything has worked out as expected and at the end in the TestCleanup you will still be able to call context.RollBack so that all changes are rolled back.
Will that work for you?
Petar
the Telerik team

Please take a look at the documentation below and if it is what you are looking for, I sent the entire program to Telerik yesterday on a ticket and I can find a way to get it to you. I went on a little journey last week to learn mocking and JustMock better as well as figure out a way to test "real" databases in memory and came up with two distinct ways to test.
dbMockTest Write Up:
The goal of this sample program is show two very different yet useful ways of testing CRUD operations that rely on business logic. This type of scenario is very common in workflows where inserts, updates and deletes have constraints which are enforced by both requirements as well as foreign key constraints in SQL server.
This demo app includes the following:
1) MDF file for sample database used in the application.
2) Visual Studio 2012 solution with two projects (program and unit test).
Requirements:
1) OpenAccess ORM (free to download via NuGet or available at Telerik.com)
2) NUnit (free to download via NuGet)
3) SQL Server 2012 LocalDB (free from Microsoft.com) or some other SQL Server. If another SQL server product is used, you will have to edit the connection strings. MDF file is include that can be attached to LocalDB through the management tools.
4) JustMock Free (available from Telerik.com)
What it does:
In the main project, Main in Program.cs carries out a very basic set of operations against a “live” SQL database. For the purposes of this demo, this is LocalDB with the include MDF file. This would simulate your production code.
In the UnitTest project however, two very distinct ways to go about performing unit tests on the production code have been implemented.
LocalDB Instance w/In Memory Changes
The first implementation (RealUserTestsUsingLocalDbChangesInMemory) leverages the .rlinq designer model file of OpenAccess which contains all of the relationships (foreign key constraints) to dynamically generate a new database in LocalDB that mimics the production database structure and relationships. Additionally, through dependency injection and by overriding SaveChanges() of the OpenAccess context for the DemoModel, the implementation was changed to call FlushChanges(). An interface is not created for the DemoModel due to the nature of the autogenerated code that is produced by OpenAccess anytime a change is made to the .rlinq file. This allows us to fully leverage the constraints of the production SQL server without ever committing those changes to the database and persist the CRUD operations in memory which allows us to receive autoinc identity values on inserts. At the end of the test run during the tear down, the dynamically generated database is destroyed. By leveraging [SetUp] and [TearDown], you can create a unique instance of the database for each individual test and by using [TestFixtureSetUp] and [TestFixtureTearDown], you are able to create a single database instance for a group of tests with the caveat that you will likely need to control the order with which the tests execute. Most would agree that this is a “smell” and should be avoided but it is useful to have the flexibility available to you.
Business Logic Tests Using JustMock
The next set of tests (MockUserTests) takes a very different approach. Instead of creating an environment that simulates the real world production environment and then cleaning up after itself, we instead mock out the various objects and even lambda expressions so that we can test purely the business logic and disconnect ourselves from any external dependencies. We still make use of [SetUp] but for the mocking tests it only serves to create the mock of the database model and instantiate a business logic handler object (production code) that we will call to invoke the various inserts, updates and deletes.

James, any chance you could email this me nikeshp4tel@gmail.com.
Regards Nikesh

Unfortunately we no longer have the project in question. As an alternative I can suggest you to post a resource request at our feedback portal. Voting for it would help us prioritize its eventual implementation. You can also check the Using the Context API sample in our Samples Kit if you are interested in seeing unit tests against a live database.
If you have any questions or need assistance, do not hesitate to contact us via our Ticket System or post in our forums again.
Regards,
Kristian Nikolov
Telerik