Esempio n. 1
0
        public void RemoveTypeMappingsGeneric_RemoveAMapping()
        {
            //Arrange
            var typeMappings = new List <TypeMapping> {
                TypeMapping.Create <ILogger, SharePointLogger>(),
                TypeMapping.Create <IConfigManager, ConfigManager>(),
                TypeMapping.Create <IHierarchicalConfig, HierarchicalConfig>()
            };

            var config = new ServiceLocationConfigData(typeMappings);
            var bag    = new BIPropertyBag();

            BSPFarm.SetLocal();
            var cfgMgr = new SIConfigManager
            {
                ContainsKeyInPropertyBagStringIPropertyBag = (key, propertyBag) => true,
                CanAccessFarmConfigGet    = () => true,
                GetPropertyBagConfigLevel = (configlevel) => bag,
            };

            cfgMgr.GetFromPropertyBagStringIPropertyBag <ServiceLocationConfigData>((key, propetyBag) => config);
            cfgMgr.BehaveAsDefaultValue();

            //Act
            var target = new ServiceLocatorConfig(cfgMgr);

            target.RemoveTypeMappings <ILogger>();
            List <TypeMapping> registeredTypeMappings =
                target.GetTypeMappings().ToList();

            //Assert
            Assert.AreEqual(2, registeredTypeMappings.Count);
            Assert.AreSame(typeMappings[1], registeredTypeMappings[0]);
            Assert.AreSame(typeMappings[2], registeredTypeMappings[1]);
        }
Esempio n. 2
0
        public void SerLocConfigRemoveTypeMappings()
        {
            List <TypeMapping>   actual;
            ServiceLocatorConfig target = new ServiceLocatorConfig();

            target.RegisterTypeMapping <IConfig, ConfigTest>();
            SharePointServiceLocator.Reset();
            Assert.IsInstanceOfType(SharePointServiceLocator.Current.GetInstance <IConfig>(), typeof(ConfigTest));
            actual = new List <TypeMapping>(target.GetTypeMappings());

            target.RemoveTypeMappings <IConfig>();
            SharePointServiceLocator.Reset();
            Assert.AreEqual(actual.Count - 1, target.GetTypeMappings().Count());
        }
Esempio n. 3
0
 /// <summary>
 /// Removes this instance.
 /// </summary>
 /// <typeparam name="TService">The type of the service.</typeparam>
 public void Remove <TService>()
 {
     _registrar.RemoveTypeMappings <TService>();
 }