Posts

Showing posts from 2012

Code Coverage in VS 2012

Image
Code Coverage is a option given for developers to make sure that the tests which they have written covers the code to be tested. Visual Studio code coverage comes with VS 2012 Test Explorer. It supports both managed & unmanaged Code. Interesting thing is as Test Explorer supports 3rd party unit testing frameworks code coverage also can be used as well. So you can use the Unit test you wish & use Code Converge toll in VS 2012 inbuilt. 1. How to use once you have run the tests you can right click on the tests in the Test Explorer & click on the on the option “ Analyze Code Coverage for Selected Tests” This will show you the code coverage result as below. This result gives you the option to navigate to the code as well. It will show code coverage percentages in following levels Total Code Coverage Assembly Level Class Level Method Level Once you clicked on any level the text editor in VS will highlight & show you which are the code blo

Microsoft Fakes isolation framework

If you want to isolate the code which you want to create tests from the the code which you don’t Microsoft fake is the solution. By isolation the code being tested make your life easier when identifying where the error is causing when a unit test fails. Types of “ Fakes ” Stub :- Replaces another class with a small substitute that implements the same interface. To use stubs, you have to design your     application so that each component depends only on interfaces, and not on other components. (By "component" we mean a class or group of classes that are designed and updated together and typically contained in an assembly.) Shim :- Modifies the compiled code of your application at run time so that instead of making a specified method call, it runs the shim code that your test provides. Shims can be used to replace calls to assemblies that you cannot modify, such .NET assemblies. When To Use As a general practice it is recommended to use Stubs for the calls

Unit Testing in VS 2012

Unit testing is a good software engineering practice which allow developers to assure the quality of the software they development from the beginning. Visual Studio 2012 provides some interesting new features to supports Test driven development mainly for the developers who practice agile practices in their day to day development tasks. In this post I’ll summarize the new features available in VS 2012 in Unit testing & will discuss each feature in detail in the next posts. Test Explorer Test Explorer is a powerful tool coming with VS2012 to run the unit tests & view the test results in Visual Studio in a more flexible manner. Test Explorer can be used to mange your test runs of the unit tests which you have written using Microsoft unit testing frameworks for managed and native code and also with the unit tests written using third party & open source unit test frameworks. Visual Studio Extension Manager and the Visual Studio gallery can be used to get these framework

Silverlight with Self hosted WCF with NetTcpBinding

Image
Advantages of using NetTcpBinding Performance: Silverlight applications using NetTcpBinding to with WCF service in your intranet   can obtain a performance gain compared to HTTP polling duplex in duplex communication scenarios. Duplex Communication: Supports Duplex communication between client and service. Helps optimize the Silverlight application (XAP) size. Applications that utilize only Steps Create WCF enabling NetTcpBinding Sample WCF Config, < system.serviceModel >     < behaviors >       < serviceBehaviors >         < behavior name = " NetTcpWCFService.ServiceBehavior " >           < serviceMetadata />           < serviceDebug includeExceptionDetailInFaults = " false " />         </ behavior >       </ serviceBehaviors >     </ behaviors >     < services >       < service behaviorConfiguration = " NetTcpWCFService "

Dynamic Filtered Views in CRM2011

If you want to create a dynamic filterd lookup in crm2011 Ex:- If you have a account lookup & a contact lookup in a form & you want to filter & view the only contacts who's parentcustomer is equal to the selected account. You can use the following var defaultViewId; // FUNCTION: formOnLoad function formOnLoad() { var lookupFieldName = 'new_contactid'; var accountFieldName = 'new_accountid'; defaultViewId = Xrm.Page.getControl(accountFieldName).getDefaultView(); setLookup(accountFieldName, lookupFieldName, false); } // FUNCTION: setLookup function setLookup(accountFieldName, lookupFieldName, resetSelection) { // Get the selected Account Id in the [accountFieldName] indicated control var account = Xrm.Page.getAttribute(accountFieldName).getValue(); if (account != null) { var accountid = account[0].id; var accountname = account[0].name; if (resetSelection == true) { //

Object type DataMembers in WCF DataContract

When we want to create a datacontract with a DataMember of the type 'object' then we have to add the KnownType Attribute for that DataContract so that the serializer will know the types allowed for that generic type. [KnownType(typeof(string))] [KnownType(typeof(int))] [KnownType(typeof(decimal))] [KnownType(typeof(float))] [KnownType(typeof(double))] [KnownType(typeof(bool))] [KnownType(typeof(char))] [KnownType(typeof(DateTime))] [KnownType(typeof(Guid))] public class RMEntity { public ConcurrentDictionary attributes = new ConcurrentDictionary (); [DataMember] public ConcurrentDictionary Attributes { get { return attributes; } set { attributes = value; } } }

Create OrganizationServiceProxy in CRM2011 IFD

Creating OrganizationServiceProxy in crm2011 IFD vs AD different when it comes to setting credentials of the service proxy. In AD :- ClientCredentials clientCredentials=new ClientCredentials(); clientCredentials.Windows.ClientCredential = new NetworkCredential(userName, password,domain); In IFD :- clientCredentials.UserName.UserName =domain + @"\" + userName; clientCredentials.UserName.Password = password; OrganizationServiceProxy service = new Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy(organizationUri, HomeRealmUri, credentials, null);