public void SettingTheScopeToSingletonSetsIsSingletonToTrue()
        {
            var att = new PluginFamilyAttribute();
            att.Scope = InstanceScope.Singleton;

            Assert.IsTrue(att.IsSingleton);
        }
예제 #2
0
 public void Process(Type type, Registry registry)
 {
     if (PluginFamilyAttribute.MarkedAsPluginFamily(type))
     {
         registry.Configure(x => x.FindFamily(type));
     }
 }
        public void UseSingletonEqualsTrueSetsScopeToSingleton()
        {
            var att = new PluginFamilyAttribute();
            att.IsSingleton = true;

            Assert.AreEqual(InstanceScope.Singleton, att.Scope);
        }
예제 #4
0
        public PluginFamily(Type pluginType, PluginGraph parent)
        {
            _parent     = parent;
            _pluginType = pluginType;

            PluginFamilyAttribute.ConfigureFamily(this);
        }
        public void UseSingletonEqualsTrueSetsScopeToSingleton()
        {
            var att = new PluginFamilyAttribute();

            att.IsSingleton = true;

            Assert.AreEqual(InstanceScope.Singleton, att.Scope);
        }
        public void SettingTheScopeToSingletonSetsIsSingletonToTrue()
        {
            var att = new PluginFamilyAttribute();

            att.Scope = InstanceScope.Singleton;

            Assert.IsTrue(att.IsSingleton);
        }
        private void assertScopeLeadsToInterceptor(string scope, Type interceptorType)
        {
            var att = new PluginFamilyAttribute();
            att.Scope = scope;

            var family = new PluginFamily(typeof (TypeThatDoesNotHaveCustomMementoSource));
            att.Configure(family);

            family.Lifecycle.ShouldBeOfType(interceptorType);
        }
        private void assertScopeLeadsToInterceptor(InstanceScope scope, Type interceptorType)
        {
            var att = new PluginFamilyAttribute("something");

            att.Scope = scope;

            var family = new PluginFamily(typeof(TypeThatDoesNotHaveCustomMementoSource));

            att.Configure(family);

            Assert.IsInstanceOfType(interceptorType, family.Lifecycle);
        }
        public void Do_not_add_a_memento_source_if_it_is_not_defined()
        {
            var mocks  = new MockRepository();
            var family = mocks.DynamicMock <IPluginFamily>();

            using (mocks.Record())
            {
                SetupResult.For(family.PluginType).Return(typeof(TypeThatDoesNotHaveCustomMementoSource));

                family.AddMementoSource(null);
                LastCall.Repeat.Never();
            }

            using (mocks.Playback())
            {
                PluginFamilyAttribute.ConfigureFamily(family);
            }
        }
        public void CreateMemoryMementoSourceWhenTheMementoSourceIsExplicitlyDefinedInAttribute()
        {
            var mocks  = new MockRepository();
            var family = mocks.DynamicMock <IPluginFamily>();

            using (mocks.Record())
            {
                SetupResult.For(family.PluginType).Return(typeof(TypeWithDesignatedMementoSource));

                family.AddMementoSource(null);
                LastCall.Constraints(Is.TypeOf <CustomMementoSource>());
            }

            using (mocks.Playback())
            {
                PluginFamilyAttribute.ConfigureFamily(family);
            }
        }
        public void PerRequest_DoesNot_call_SetScopeTo_on_family()
        {
            var att = new PluginFamilyAttribute("something");
            att.Scope = InstanceScope.PerRequest;

            var mocks = new MockRepository();
            var family = mocks.DynamicMock<IPluginFamily>();

            using (mocks.Record())
            {
                family.SetScopeTo(InstanceScope.PerRequest);
                LastCall.Repeat.Never();
            }

            using (mocks.Playback())
            {
                att.Configure(family);
            }
        }
        public void PerRequest_DoesNot_call_SetScopeTo_on_family()
        {
            var att = new PluginFamilyAttribute("something");

            att.Scope = InstanceScope.PerRequest;

            var mocks  = new MockRepository();
            var family = mocks.DynamicMock <IPluginFamily>();

            using (mocks.Record())
            {
                family.SetScopeTo(InstanceScope.PerRequest);
                LastCall.Repeat.Never();
            }

            using (mocks.Playback())
            {
                att.Configure(family);
            }
        }
        private void assertScopeLeadsToInterceptor(InstanceScope scope, Type interceptorType)
        {
            var att = new PluginFamilyAttribute("something");
            att.Scope = scope;

            var family = new PluginFamily(typeof (TypeThatDoesNotHaveCustomMementoSource));
            att.Configure(family);

            Assert.IsInstanceOfType(interceptorType, family.Lifecycle);
        }