public static void ReplaceObjectDefinition(this IConfigurableApplicationContext applicationContext, string name,
                                            IObjectDefinition definition)
 {
     if (definition?.ObjectType != typeof(SurrogateFactoryObject))
     {
         // Proceed here if the object definition will replace the object definition of the
         // SurrogateFactoryObject type.
         var factoryObject = applicationContext.GetFactoryObject(name);
         if (factoryObject is SurrogateFactoryObject && factoryObject.IsSingleton)
         {
             // If it happens that Sprint.NET decides to cache this singleton object, then
             // proceed to clear its state, like call counters. This is to make sure that
             // a new test starts with a clean mock/spy surrogate.
             var fakeObject = applicationContext.GetObject(name);
             FakeItEasy.Fake.ClearRecordedCalls(fakeObject);
         }
     }
     applicationContext.ObjectFactory.RemoveSingleton(name);
     applicationContext.RegisterObjectDefinition(name, definition);
 }