It has been a year since I wrote the article about unit testing with ServiceLocator. But, there are two things worth updating - replacing obsolete FormatterServices and use scoped service provider.
By default Optimizely code does not remove properties from the database when you remove them from the code - This article describes how to remove obsolete Commerce data and introduces the Opti.Addons project.
One of the feature of the C# allows to swap values via deconstruction (without using temporary variable). It was introduced while ago (C# 7.0), but I oversaw it. It's a nice feature that allows to swap values in a very elegant way.
Charles is a tool that enables to view all HTTP(S) traffic between the current system and the Internet. Here I will show how to setup Charles to catch the localhost traffic with the example of ASP.NET Core and the EPiServer Foundation project.
Optimizely Search & Navigation (a.k.a. EPiServer Find) is a powerful engine but, as being a black box, it might be difficult to diagnose its behavior when things go wrong. This article describes how to make a deep dive into the search engine and get the insights about the underlying query.
Optimizely allows to obtain the ID of the anonymous user (even if the user is logged in). One of the example of the usage is merging cart when the user logs in.
Optimizely invokes its internal validators for the cart processing by default. This article describes how to skip this validation in scenarios where custom validation logic is in place, or we don't want UI to update the cart when viewing it.
Debugging multi-threaded applications might be challenging. Setting a breakpoint in a multi-threaded context might be run multiple times, making the debugging process difficult. However, JetBrains Rider allows you to make one simple trick to debug only a single thread for a certain breakpoint.
When it comes to debugging, there might be a case when the load of calls to the breakpoint is significant. Or, we want to log some data while debugging. In this case, it is useful to do not suspend the execution and evaluate the breakpoint condition and log the result (In JetBrains Rider).
Some testing classes may have a dependency to the ServiceLocator, so the dependencies are injected via property, for example. That makes class more difficult to unit test. In this post I will present how to write unit test for a class with dependency to ServiceLocator, with the real world example of Optimizely.
In some cases, there are classes with constructors that are impossible to mock with proxy-based mocking frameworks (such as Moq, FakeItEasy, NSubstitute, etc). In this article, I will present how to create a test for class that is impossible to mock.