Load Test in Windows Azure with Visual Studio Test Agents
Tomorrow I will be presenting “Load Test in Windows Azure with Visual Studio Test Agents” on MSDN. Hope to see you there.
Register here.
Sharing my daily work experience..
Tomorrow I will be presenting “Load Test in Windows Azure with Visual Studio Test Agents” on MSDN. Hope to see you there.
Register here.
Published By
Javier Arguello
at
10:12 PM
0
comments
Labels: ALM, Azure, Testing, Visual Studio
As several people have found, Moles does not work well with DLR. Check Cameron’s post for this issue.
In order to make it work do the following:
I haven’t done further testing on changing the use of legacy CAS Policy when using Moles & VS Test Framework.
Let me know how it works for you.
Published By
Javier Arguello
at
6:45 PM
0
comments
In recent years there’s been major investments in developing tools in order to provide good quality assurance features and incorporate industry practices into them.
TDD, DDD, Unit Testing, Continuous Integration, etc.
Microsoft has recently (not so recently actually :)) ship some very nice features to help us improve our code quality by allowing us to create better tests over units of code.
Unit testing is all about proving individual units of code (positive and negative testing). Since a great deal of software is not always designed with this “unit independence” in mind, it can be a challenge to isolate dependencies for every piece of source code (specially legacy code).
Moles is an Isolation Framework that mocks/emulates the behavior of our components and external libraries, even for private members. You could even mock how a particular System.* class object in .NET behaves (check Pex & Moles site in Microsoft Research).
The following is a Repository object that uses Linq to Sql Data Context internally and doesn't provide a simple way of decoupling database access from its behavior. It means we cannot unit test the following class without a SQL database.
By using Moles, we could replace inner behavior of this class.
Note: This is White Box Testing, meaning you need to have access to internal implementation in order to know how to mock it.
Mocking with Moles
Download and install Moles.
Check this tutorial about Pex & Moles for more information about the previous steps.
The following code fragment unit test our GetCustomers method:
Check out the use of Moles to specify the behavior of enumeration for the Table<Customer> (Customers) that Linq to Sql Provider uses to execute the query in the database. In the previous code, we avoid querying data from database and return an in-memory list of customers.
When executing a lambda expression using Linq to Sql, the source Linq provider must interpret the query and then issue a command to the database.
In order to intercept the query and return mock results, we must override default behavior for the expression evaluation logic of the Linq Provider.
The previous mocking code returns a Mock QueryProvider that does not evaluate the expression, it simply returns the in-memory customer reference.
I encourage you that read more about Moles here.
PS: This cool framework intercepts any managed operation by creating a CLR Host for the application.
Published By
Javier Arguello
at
12:22 PM
0
comments
Labels: Moles, Testing, Unit Test, Visual Studio
If you haven´t installed Visual Studio 2010 SP1 yet and you’ve enabled automatic Windows Update, chances are you end up getting the following error when starting VS2010: Exception has been thrown by the target of an invocation.
There is a .NET 4 Framework in Windows update distributed recently that generates this conflict.
Solution: Install VS2010 Sp1.
Published By
Javier Arguello
at
10:50 AM
0
comments
Labels: Visual Studio
Next Wednesday (April 27th) I will presenting Parallel LINQ and showing some not trivial stuff to optimize performance in parallel algorithms. Register here.
Published By
Javier Arguello
at
12:52 AM
0
comments
Labels: C#, PLINQ, Visual Studio
I will be participating as an invited speaker in “Comunidad.NET” in Mexico City next Tuesday (April 26th). My presentation will be focusing code quality using Visual Studio Tools.
Agenda:
You can get more info from Raul’s blog.
Published By
Javier Arguello
at
12:30 AM
0
comments
Labels: ALM, Visual Studio
Sometime ago I published a way to use WCF service with the new Async Pattern in C#. The problem is that this approach won’t work with Silverlight. More specifically, TaskFactory is not available in Silverlight.
So.. here is one solution (it does not provide full functionality as in TaskFactory, but you can manage 90% of use cases):
The previous code fragment defines a helper method that behaves similar to TaskFactory.
Usage example:
And here is the service extension for MyServiceClient (Note that I use the service interface contract instead of the ClientBase<> as parameter since we need access to Begin/End methods):
Try it and let me know if it works for you..
Published By
Javier Arguello
at
11:30 PM
0
comments
Labels: Async, C#, Languages, Silverlight, Visual Studio