Ejemplo n.º 1
0
        public static void Init(TestContext context)
        {
            Configuration = ObjectChangeTracking.CreateConfiguration()
                            .TrackThisType <A>()
                            .TrackThisType <TestDynamicObject>();

            TrackableObjectFactory = Configuration.CreateTrackableObjectFactory();
        }
        public static void Init(TestContext context)
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

            config.TrackThisType <IWhatever>();

            TrackableObjectFactory = config.CreateTrackableObjectFactory();
        }
Ejemplo n.º 3
0
        public void Initialize()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

            config.TrackThisTypeRecursive <Class0>();

            _trackableObjectFactory = config.CreateTrackableObjectFactory();
        }
Ejemplo n.º 4
0
        public void CanConfigureAbstractClass()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

            config.TrackTypesFromAssembly(typeof(ConfigurationTest).GetTypeInfo().Assembly, searchSettings: new TypeSearchSettings
            {
                Mode = TypeSearchMode.AttributeConfigurationOnly,
                /*Filter = t => t == typeof(AbstractClass) || t == typeof(DerivesAbstractClass),*/
                Recursive = true
            });

            ITrackableObjectFactory factory = config.CreateTrackableObjectFactory();
            var x = factory.CreateFrom(new DerivesAbstractClass());
        }
Ejemplo n.º 5
0
        public static void Init(TestContext context)
        {
            Configuration = ObjectChangeTracking.CreateConfiguration()
                            .TrackThisType <A>(t => t.IncludeProperty(a => a.Items))
                            .TrackThisType <B>(t => t.IncludeProperty(b => b.Dogs))
                            .TrackThisType <C>(t => t.IncludeProperty(c => c.Dogs))
                            .TrackThisType <Dog>(t => t.IncludeProperty(d => d.Name))
                            .TrackThisType <D>()
                            .TrackThisType <E>(t => t.IncludeProperty(e => e.Dictionary))
                            .TrackThisType <F>(t => t.IncludeProperty(f => f.ListOfF))
                            .TrackThisType <G>(t => t.IncludeProperty(g => g.Buffer))
                            .TrackThisType <WhateverBase>(t => t.IncludeProperty(w => w.List2))
                            .TrackThisType <WhateverParent>(t => t.IncludeProperty(w => w.List));

            TrackableObjectFactory = Configuration.CreateTrackableObjectFactory();
        }
Ejemplo n.º 6
0
        public void CanConfigureWithNestedTypes()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

            config.TrackTypesFromAssembly(typeof(ConfigurationTest).GetTypeInfo().Assembly, searchSettings: new TypeSearchSettings
            {
                Mode   = TypeSearchMode.AttributeConfigurationOnly,
                Filter = t => t == typeof(ClassWithNestedEnum) || t == typeof(DerivedClassWithNestedEnum)
            });

            ITrackableObjectFactory factory = config.CreateTrackableObjectFactory();

            DerivedClassWithNestedEnum instance = factory.CreateOf <DerivedClassWithNestedEnum>();

            Assert.IsNotNull(instance);
        }
Ejemplo n.º 7
0
        public void CanConfigureClassWithMultipleConstructors()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

            config.TrackTypesFromAssembly(typeof(ConfigurationTest).GetTypeInfo().Assembly, searchSettings: new TypeSearchSettings
            {
                Mode   = TypeSearchMode.AttributeConfigurationOnly,
                Filter = t => t == typeof(WithMultipleConstructors)
            });

            ITrackableObjectFactory factory = config.CreateTrackableObjectFactory();

            WithMultipleConstructors instance = factory.CreateFrom(new WithMultipleConstructors());

            Assert.IsNotNull(instance);
        }
Ejemplo n.º 8
0
        public void CanConfigureClassWithReadOnlyProperties()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

            config.TrackTypesFromAssembly(typeof(ConfigurationTest).GetTypeInfo().Assembly, searchSettings: new TypeSearchSettings
            {
                Mode   = TypeSearchMode.AttributeConfigurationOnly,
                Filter = t => t == typeof(ClassWithReadOnlyProperties)
            });

            ITrackableObjectFactory factory = config.CreateTrackableObjectFactory();

            ClassWithReadOnlyProperties instance = factory.CreateFrom(new ClassWithReadOnlyProperties());

            instance.Text = "hey";

            IObjectChangeTracker tracker = instance.GetChangeTracker();

            Assert.AreEqual(1, tracker.ChangedProperties.Count);
            Assert.AreEqual(1, ((ObjectChangeTracker)tracker).PropertyTrackings.Count);
        }
Ejemplo n.º 9
0
        public void CanConfigureNonTrackablePropertiesFromBaseClasses()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

            config.TrackTypesFromAssembly(typeof(ConfigurationTest).GetTypeInfo().Assembly, searchSettings: new TypeSearchSettings
            {
                Mode      = TypeSearchMode.AttributeConfigurationOnly,
                Recursive = true,
                Filter    = t =>
                {
                    return(t.DeclaringType == typeof(ConfigurationTest));
                }
            });

            ITrackableObjectFactory trackableObjectFactory      = config.CreateTrackableObjectFactory();
            DerivedClassOfBaseClassWithNonTrackableProperty obj = trackableObjectFactory.CreateOf <DerivedClassOfBaseClassWithNonTrackableProperty>();

            IObjectChangeTracker changeTracker = obj.GetChangeTracker();

            Assert.AreEqual(1, changeTracker.Count());
            Assert.IsTrue(changeTracker.First().PropertyName == "Text2");
        }