Tuesday, May 17, 2016

3rd party plugin/api’s for writing better test cases in Mvc

Tools for automating test cases are WaitN , Lightweight Test Automation Framework, Selenium(automating web applications for testing purposes).

SpecBind Selenium Module -- An extension to SpecBind that allows it to integrate with Selenium

1. What is SpecBind?

SpecBind is an extension to SpecFlow that uses common language steps to allow a user to define interaction with an application. Unlike conventional SpecFlow where the user needs to define how each step definition interacts with the host system, SpecBind uses conventions and a thin page model to minimize coding efforts and maximize flexibility when defining the link between specifications and working sites.
Bridges the SpecFlow and popular UI automation frameworks to simplify acceptance tests. For more info https://github.com/dpiessens/specbind/wiki#Linking-Navigation http://www.specflow.org/
If you are new to spec flow please go through the link http://www.specflow.org/getting-started/

2. What is Fluent Assertions?

Fluent Assertions is a set of .NET extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style test.
FluentAssertions is an alternative assertion library for unit tests, to use instead of the methods in Assert class that Microsoft provides. It has much better support for exceptions and some other stuff that improves readability and makes it easier to produce tests.

3. What is moq testing? 

Moq is a third party library/framework that enables you to create the dummy class and its methods’ dummy implementation without actually creating a class with actual method implementation. Here you need to note that you need to provide the interface name for creating dummy class which will implement interface methods as dummy. This is very useful in the scenarios where you want to test the functionality of a class without implementing the other classes and their methods on which the test candidate class is dependent on.

4. Create test data with NBuilder and Faker

For many web applications you may want to generate some initial, semi-realistic test data for your development and testing environments. Entity Framework provides a handy mechanism through which you can achieve this, namely seed data.
When it comes to generating the test data, I personally make use of two 3rd party libraries, namely NBuilder and Faker.NET. Both these libraries have not been updated for a long time, but they still work just fine. http://www.jerriepelser.com/blog/creating-test-data-with-nbuilder-and-faker
Faker.NET is a port of a popular Ruby project called faker. It allows you to generate a wide range of realistic looking data, including names, addresses, telephone numbers, internet domains, sentences, etc.

6. What is AutoMapper in mvc? 

AutoMapper is used to reduce the complexity we find when binding the model and communicating with entities. http://www.c-sharpcorner.com/UploadFile/tirthacs/using-automapper-in-mvc/

AutoMapper is an open source library provided by GitHub. The Codeplex page says about AutoMapper: “AutoMapper is an object-object mapper. Object-object mapping works by transforming an input object of one type into an output object of a different type. What makes AutoMapper interesting is that it provides some interesting conventions to take the dirty work out of figuring out how to map type A to type B. As long as type B follows AutoMapper's established conventions, almost zero configurations is needed to map two types”. As per the definition it solves our issue. You can get the AutoMapper from the following website:AutoMapper.


Thursday, May 5, 2016

Sitecore Basic Key Skills

1.      Multi device and Multi-lingual site creation.
2.      Security in sitecore ( Role Based and  user based security)
3.      Workflow
4.      Solr/lucene search
5.      Some shared source modules like news mover, partial language fallback, we blog and forum
6.      Creation and Installation of packages
7.      Basics of sitecore like creation of templates, subalyout, layouts and placeholders
8.      Associating(Mapping) controls (sublayouts) to visual studio
9.      Command templates, standard template and branch templates
10.  Item bucket concept in sitecore
11.  Publishing, creating publishing targets -- publishing modes
12.  Custom ribbons and custom commands in sitecore
13.  Page Editor features in sitecore
14.  Creating Scheduler  in sitecore  
15.  Configuring DMS in Sitecore
16.  Creation of Goals, tracking the user activity in the page
17.  Campaign management in sitecore
18.  Sitecore Executive Dashboard
19.  Integrating third party control in sitecore like Google analytics, Google Maps, Twitter API, Social Sharing controls etc. 
20.  Engagement analytics and reports in sitecore
21.  Some fundamental concepts about Master, Core and Web Database
22.  Some hidden features of sitecore that every developer should know about it.
23.  Creating patch files.
24.  Sitecore Best practices
25.  Web form for marketers
26.  Build, Deployment and knowledge cm and cd servers
27.  Knowledge about versioned, un-versioned templates, Shared fields & Un-versioned  fields.
28.  Data types in Sitecore Multilist, TreeList, Treelist-ex, Droplist, DropLink, Gerneral link etc.
29.  Difference between TreeList and TreeList-ex
30.  Difference between DropList and Droplink
31.  Serialization in sitecore, rebuilding index.
32.  Building Xpath and fast queries in sitecore
33.  Knowledge web config setting.
34.  Pipeline and events in sitecore   ---- Important
35.  Registering Goals programmatically and triggering the goals programmatically and based on the user action.
36.  Caching in sitecore at subalyout level and the page level 
37.  Rendering Parameters and Data source in sitecore
38.  Lucene search configuration in sitecore
39.  Publishing restriction in sitecore
40.  Adding item versions, deleting and publishing specific item version.
41.  Translation in sitecore
42.  Validation in sitecore
43.  Setting layout details in standard values and setting the standard values for field.
44.  SEO toolkit in sitecore
45.  Sitecore Rock
46.  Persalization in sitecore
47.  Structure of sites in sitecore
48.  HTML Editor profiles in sitecore
49.  Event Queue in sitecore
50.  What is new in sitecore 7.5

Wednesday, May 4, 2016

Implementing simple search functionality in Sitecore using Solr

Ø  Refer the link to configure solr Sitecore Search and indexing --https://sdn.sitecore.net/upload/sitecore6/65/sitecore_search_and_indexing_sc60-65-a4.pdf


This is continuous of my previous blog post “step-by-step-guide-for-setting-up-solr” For implementing simple search page create a search controller, sear result page and search helper classes (models). See the below image for reference.



Index Definition
An index is a physical file populated by a crawler and stored in the data folder of the Website. In Sitecore, an ‘index’ can serve a number of different purposes:
·   From a configuration perspective, an index is a searchable database with a collection of crawlers that populate a database. An Index is identified by its name and stores data in a physical location in the data folder.
     ·   From end-user perspective, an index is a searchable database of documents which links to        actual Sitecore items.

Creating a custom index in Solr
   You can create your own custom search index or you can use the indexes that ships with Sitecore by default such as “sitecore_web_index”.
 To create custom search index in solr you need to go to following node
 <contentSearch> <configuration> <indexes>  and duplicate the exsting index and change the index id ( provide name of your custom index). Please refer the below screen shot for the same.



Configure root node for custom index i.e location of sitecore content tree which u need to index. Please refer the below screen shot for the same.



Understanding parameters of custom index
·         index id : This id we will use in our code to query the search results.
·         <param desc="core">$(id)</param> : name of the core where ur search indexes   are stored.
·         Configuration: By default it will point to the defaultSolrIndexConfiguration node, you can create your own SolrIndexConfiguration node, this is the node which has most of the solr configuration settings.
·         Strategy: This node has list of the different indexing strategies that you can use. You can also combine these strategies to achieve what you want.
·         Crawler: defines which database it should crawl, and where to start.
Refer the below screen shot



Default Solr Index configuration settings
When we look at the config file namedSitecore.ContentSearch.Solr.DefaultIndexConfiguration”, we see lot of configuration setting. One should be aware of some of the common settings such as
·         indexAllFields: Basically this is the master setting, index every field by default or not. The default setting is true
·         fieldNames hint=”raw:AddfieldByFieldName”: This allow you to specifiy how fields will be indexed based on fieldname.
·         fieldTypes hint=”raw:AddFieldByFieldTypeName”: This allow you to specifly how fields will be indexed based on fieldtype
·         Exclude hint=“list:ExcludeTemplate”: this allow you to exclude a specific template to be indexed, use this if you used true as a value for the indexAllfields setting.
·         Exclude hint=”list:ExcludeField”: this allow you to exclude a specific field from your index, use this if you used true as a value for the indexAllfields setting.
·         Include hint:”list:IncludeTempalte”: this allow you to include a specific template to be indexed, use this if you used false as a value for the indexAllfields setting.
·         Include hin:”list:IncludeField”: this allow you to include a specific field to be indexed, use this if you used false as a value for the indexAllfields setting.

Creating custom class for solr search
Before utilizing the created custom index create a custom class that inherits from SearchResultItem, and then implements the field we added to the index.

    public class CustomSearchResultItem : SearchResultItem
    {
        [IndexField("Title")]
        public string Title { get; set; }

          [IndexField("Name")]
        public string Name { get; set; }

          [IndexField("Categories")]
        public string Categories { get; set; }
     }
This will enable you to utilize LINQ to Sitecore like this
var query = context.GetQueryable< SearchHelper >().Where(i => i.Categories.Contains(categoryID));

Writing code for query the search results


Predicate builder
Allows you to create more complex queries using AND and OR and it generates complex Expression trees without having to know about their inner workings.

Switch Solr indexes
·         You can set up Solr to rebuild an index in a separate core so that the rebuilding does not affect the search index that is currently used. Once the rebuilding and the optimization of the index completes, Sitecore switches the two cores, and the rebuilt and optimized index is used.
·         The SwitchOnRebuildSolrSearchIndex class inherits from the SolrSearchIndex class and adds the capability of maintaining two cores for a particular index. Because this is only important for production environments, you can reconfigure your custom index with the SwitchOnRebuildSolrSearchIndex implementation during testing and before moving to a production environment.
     For more detail please see the blog post: https://doc.sitecore.net/sitecore_experience_platform/setting_up__maintaining/search_and_indexing/indexing/switch_solr_indexes


 Sitecore computed index fields
·         A computed index field allows you to perform additional processing before adding data to an index. For example, you may want to store the contents of a droplink field (the raw value being a GUID) as the target item's name, or a particular field value from the target item.
            For building a computed field and debugging please refer below blog post: