Exemplo n.º 1
0
        public void RegisterObjectDefinitionSunnyDay()
        {
            ObjectDefinitionHolder holder = new ObjectDefinitionHolder(definition, "foo");

            ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, registry);

            A.CallTo(() => registry.RegisterObjectDefinition(null, null)).WithAnyArguments().MustHaveHappened();
        }
Exemplo n.º 2
0
        public void RegisterObjectDefinitionSunnyDayWithAliases()
        {
            ObjectDefinitionHolder holder = new ObjectDefinitionHolder(definition, "foo", new string[] { "bar", "baz" });

            ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, registry);

            A.CallTo(() => registry.RegisterObjectDefinition("foo", definition)).MustHaveHappened();
            A.CallTo(() => registry.RegisterAlias("foo", "bar")).MustHaveHappened();
            A.CallTo(() => registry.RegisterAlias("foo", "baz")).MustHaveHappened();
        }
        public void RegisterObjectDefinitionSunnyDay()
        {
            registry.RegisterObjectDefinition(null, null);
            LastCall.IgnoreArguments();
            mocks.ReplayAll();

            ObjectDefinitionHolder holder = new ObjectDefinitionHolder(definition, "foo");

            ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, registry);
            mocks.VerifyAll();
        }
Exemplo n.º 4
0
        public void RegisterObjectDefinitionWithDuplicateAlias()
        {
            registry.RegisterObjectDefinition("foo", definition);

            // we assume that some other object defition has already been associated with this alias...
            A.CallTo(() => registry.RegisterAlias(null, null)).WithAnyArguments().Throws <ObjectDefinitionStoreException>();

            ObjectDefinitionHolder holder
                = new ObjectDefinitionHolder(definition, "foo", new string[] { "bing" });

            Assert.Throws <ObjectDefinitionStoreException>(() => ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, registry));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Generates an object name for the given object definition.
        /// </summary>
        /// <param name="definition">The object definition to generate a name for.</param>
        /// <param name="registry">The object definitions registry that the given definition is
        /// supposed to be registerd with</param>
        /// <returns>the generated object name</returns>
        public string GenerateObjectName(IObjectDefinition definition, IObjectDefinitionRegistry registry)
        {
            IConfigurableObjectDefinition objectDef = definition as IConfigurableObjectDefinition;

            if (objectDef == null)
            {
                throw new ArgumentException(
                          "DefaultObjectNameGenerator is only able to handle IConfigurableObjectDefinition subclasses: " +
                          definition);
            }
            return(ObjectDefinitionReaderUtils.GenerateObjectName(objectDef, registry));
        }
        public void RegisterObjectDefinitionSunnyDayWithAliases()
        {
            registry.RegisterObjectDefinition("foo", definition);
            registry.RegisterAlias("foo", "bar");
            registry.RegisterAlias("foo", "baz");
            mocks.ReplayAll();

            ObjectDefinitionHolder holder = new ObjectDefinitionHolder(definition, "foo", new string[] { "bar", "baz" });

            ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, registry);

            mocks.VerifyAll();
        }
        public void RegisterObjectDefinitionWithDuplicateAlias()
        {
            registry.RegisterObjectDefinition("foo", definition);

            // we assume that some other object defition has already been associated with this alias...
            registry.RegisterAlias(null, null);
            LastCall.IgnoreArguments().Throw(new ObjectDefinitionStoreException());
            mocks.ReplayAll();

            ObjectDefinitionHolder holder
                = new ObjectDefinitionHolder(definition, "foo", new string[] { "bing" });

            try
            {
                ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, registry);
                Assert.Fail("Must have thrown an ObjectDefinitionStoreException store by this point.");
            }
            catch (ObjectDefinitionStoreException)
            {
                // expected...
            }

            mocks.VerifyAll();
        }
 public void RegisterObjectDefinitionWithAllArgumentsNull()
 {
     ObjectDefinitionReaderUtils.RegisterObjectDefinition(null, null);
 }
Exemplo n.º 9
0
 public void RegisterObjectDefinitionWithAllArgumentsNull()
 {
     Assert.Throws <ArgumentNullException>(() => ObjectDefinitionReaderUtils.RegisterObjectDefinition(null, null));
 }
Exemplo n.º 10
0
        public void RegisterObjectDefinitionWithNullRegistry()
        {
            ObjectDefinitionHolder holder = new ObjectDefinitionHolder(definition, "foo");

            Assert.Throws <ArgumentNullException>(() => ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, null));
        }
Exemplo n.º 11
0
 public void RegisterObjectDefinitionWithNullDefinition()
 {
     Assert.Throws <ArgumentNullException>(() => ObjectDefinitionReaderUtils.RegisterObjectDefinition(null, registry));
 }
 public void GenerateObjectNameWithNullDefinition()
 {
     ObjectDefinitionReaderUtils.GenerateObjectName(null, registry);
 }
Exemplo n.º 13
0
 public void GenerateObjectNameWithNullRegistry()
 {
     Assert.Throws <ArgumentNullException>(() => ObjectDefinitionReaderUtils.GenerateObjectName(A.Fake <IConfigurableObjectDefinition>(), null));
 }
Exemplo n.º 14
0
 public void GenerateObjectNameWithNullDefinition()
 {
     Assert.Throws <ArgumentNullException>(() => ObjectDefinitionReaderUtils.GenerateObjectName(null, registry));
 }
 public void GenerateObjectNameWithNullRegistry()
 {
     ObjectDefinitionReaderUtils.GenerateObjectName(mocks.StrictMock <IConfigurableObjectDefinition>(), null);
 }
        public void RegisterObjectDefinitionWithNullRegistry()
        {
            ObjectDefinitionHolder holder = new ObjectDefinitionHolder(definition, "foo");

            ObjectDefinitionReaderUtils.RegisterObjectDefinition(holder, null);
        }
 public void RegisterObjectDefinitionWithNullDefinition()
 {
     ObjectDefinitionReaderUtils.RegisterObjectDefinition(null, registry);
 }
 public void GenerateObjectNameWithNullRegistry()
 {
     ObjectDefinitionReaderUtils.GenerateObjectName(
         (IConfigurableObjectDefinition)mocks.CreateMock(typeof(IConfigurableObjectDefinition)),
         null);
 }