Posts

Showing posts from October, 2021

Unit Test for Sitecore Custom Personalization Rule

Image
I assume that in your career path you all become chance to hands on implementation for Sitecore Custom Personalization Rule. If you did not, then I have already described in detail about Custom Personalization Rule implementation in my one of previous blog. See the Blog Post: Custom Personalization Rules in Sitecore Today I am going to share with you about implementation of Unit Test for Custom Personalization Rule. Custom Personalization Rule business logic: protected override bool Execute(T ruleContext) { if (_pageContext != null && !string.IsNullOrWhiteSpace(_pageContext.baseketValue)) { var deliveryType = _basketDetailsService.GetBasket(_pageContext.basketValue).deliveryType; if (deliveryType != null && deliveryType== DeliveryType.CashOnDelivery) { return true; } } return false; } In above sample piece of code, I have created two Serv...