/// <summary> /// Runs Uninitialize, ConfigureContainer, and Initialize on the class <see cref="CommerceInitialization"/>. /// </summary> /// <remarks> /// This is needed because EPiServer.Commerce have singletons that holds data. /// When restoring the database, the data in the singelton will contain data from previous tests. /// That is why these tests needs to reinitialize EPiServer Commerce /// </remarks> private static void ReInitializeCommerceInitializationModule() { if (_engine == null) { var engineFiledInfo = typeof(InitializationModule).GetField("_engine", BindingFlags.Static | BindingFlags.NonPublic); if (engineFiledInfo == null) { throw new InvalidOperationException( "The class 'EPiServer.Framework.Initialization.InitializationModule' didn't contain a private static field with the name '_engine'. " + "This field has been changed or removed. The initialization of the integration tests needs to be updated."); } _engine = (InitializationEngine)engineFiledInfo.GetValue(null); } if (_serviceConfigurationContext == null) { var containerPropertyInfo = _engine.GetType().GetProperty("Container", BindingFlags.Instance | BindingFlags.NonPublic); if (containerPropertyInfo == null) { throw new InvalidOperationException("The class 'EPiServer.Framework.Initialization.InitializationEngine' didn't contain an internal property with the name 'Container'. " + "This property has been changed or removed. The initialization of the integration tests needs to be updated."); } var container = containerPropertyInfo.GetValue(_engine, null) as IContainer; _serviceConfigurationContext = new ServiceConfigurationContext(HostType.TestFramework, container); } if (_commerceInitialization == null) { _commerceInitialization = new CommerceInitialization(); } _commerceInitialization.ConfigureContainer(_serviceConfigurationContext); }