Example #1
0
        static string GetMultiClusterRegistration(RegistrationAttribute registration)
        {
            switch (registration)
            {
            case GlobalSingleInstanceAttribute gs: return(typeof(GlobalSingleInstanceAttribute).Name);

            case OneInstancePerClusterAttribute one: return(typeof(OneInstancePerClusterAttribute).Name);

            default:
                throw new InvalidOperationException($"Unsupported {nameof(RegistrationAttribute)}: {registration.GetType()}");
            }
        }
Example #2
0
        public static void RegistrationTest(RegistrationAttribute attributeUnderTest, Hashtable expectedValues, BaseRegistrationContextMock contextMock)
        {
            attributeUnderTest.Register(contextMock);

            //Verify if the number of the registry entries is the same
            Assert.IsTrue(contextMock.RegistryEntries.Count == expectedValues.Count);

            //Verify each entry
            foreach (object regKeyName in contextMock.RegistryEntries.Keys)
            {
                Hashtable valDataActual, valDataExpected;
                Assert.IsNotNull(valDataActual   = (Hashtable)(((RegistrationKeyMock)contextMock.RegistryEntries[regKeyName])).Keys);
                Assert.IsNotNull(valDataExpected = (Hashtable)expectedValues[regKeyName]);
                Assert.AreEqual(valDataExpected.Count, valDataActual.Count);
                foreach (object valueName in valDataActual.Keys)
                {
                    Assert.IsTrue(string.Compare(valDataActual[valueName.ToString()].ToString(), valDataExpected[valueName.ToString()].ToString(), true) == 0);
                }
            }
        }
 /// <summary>
 /// This scenario verifies the Unregister method
 /// </summary>
 public static void UnRegistrationTest(RegistrationAttribute attributeUnderTest, BaseRegistrationContextMock contextMock)
 {
     attributeUnderTest.Unregister(contextMock);
     Assert.IsTrue(contextMock.RegistryEntries.Count == 0);
 }
        public static void RegistrationTest(RegistrationAttribute attributeUnderTest, Hashtable expectedValues, BaseRegistrationContextMock contextMock)
        {
            attributeUnderTest.Register(contextMock);

            //Verify if the number of the registry entries is the same
            Assert.IsTrue(contextMock.RegistryEntries.Count == expectedValues.Count);

            //Verify each entry
            foreach (object regKeyName in contextMock.RegistryEntries.Keys)
            {
                Hashtable valDataActual, valDataExpected;
                Assert.IsNotNull(valDataActual = (Hashtable)(((RegistrationKeyMock)contextMock.RegistryEntries[regKeyName])).Keys);
                Assert.IsNotNull(valDataExpected = (Hashtable)expectedValues[regKeyName]);
                Assert.AreEqual(valDataExpected.Count, valDataActual.Count);
                foreach (object valueName in valDataActual.Keys)
                    Assert.IsTrue(string.Compare(valDataActual[valueName.ToString()].ToString(), valDataExpected[valueName.ToString()].ToString(), true) == 0);
            }
        }
Example #5
0
 /// <summary>
 /// This scenario verifies the Unregister method
 /// </summary>
 public static void UnRegistrationTest(RegistrationAttribute attributeUnderTest, BaseRegistrationContextMock contextMock)
 {
     attributeUnderTest.Unregister(contextMock);
     Assert.IsTrue(contextMock.RegistryEntries.Count == 0);
 }
        /// <summary>
        /// Look for an existing component in the kernel
        /// </summary>
        public static bool AllreadyRegistered(IKernel kernel, Type foundComponent, RegistrationAttribute regAtt)
        {
            var name = regAtt == null || string.IsNullOrEmpty(regAtt.Name) ? foundComponent.FullName : regAtt.Name;

            return(kernel.HasComponent(name));
        }
 public override void Unregister(RegistrationAttribute.RegistrationContext context)
 {
     context.RemoveKey(ExceptionKey);
 }
        public override void Register(RegistrationAttribute.RegistrationContext context)
        {
            var engineKey = context.CreateKey(ExceptionKey);
            var key = engineKey;
            foreach (var pathElem in _path)
            {
                key = key.CreateSubkey(pathElem);
            }

            key.SetValue("Code", _code);
            key.SetValue("State", _state);
        }
 public override void Unregister(RegistrationAttribute.RegistrationContext context)
 {
     ProvideObjectAttribute objectProvider = new ProvideObjectAttribute(context.ComponentType);
     objectProvider.Unregister(context);
 }