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();
        }
Esempio n. 3
0
        public void Initialize()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

            config.TrackThisTypeRecursive <Class0>();

            _trackableObjectFactory = config.CreateTrackableObjectFactory();
        }
Esempio n. 4
0
        public EinstellungenViewModel()
        {
            var trackerConfig = ObjectChangeTracking.CreateConfiguration();

            trackerConfig.TrackThisType <Settings>();

            var trackableObjectFactory = trackerConfig.CreateTrackableObjectFactory();

            _settings = trackableObjectFactory.CreateFrom(Settings.GetSettings());
        }
Esempio n. 5
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());
        }
Esempio n. 6
0
        public void ConfiguresClassWithAllPropertiesExceptingNonTrackable()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

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

            ITrackableType trackableType = config.TrackableTypes.Single();

            Assert.AreEqual(1, trackableType.IncludedProperties.Count);
            Assert.AreEqual("Text", trackableType.IncludedProperties.Single().Name);
        }
Esempio n. 7
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();
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        public void ConfiguresClassWithAllProperties()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

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

            ITrackableType trackableType = config.TrackableTypes.Single();

            Assert.AreEqual(2, trackableType.IncludedProperties.Count);
            Assert.IsTrue(trackableType.IncludedProperties.Any(p => p.Name == "Text"));
            Assert.IsTrue(trackableType.IncludedProperties.Any(p => p.Name == "Text2"));
        }
        public static void Init(TestContext context)
        {
            Configuration = ObjectChangeTracking.CreateConfiguration()
                            .TrackThisType <A>(t => t.IncludeProperties(a => a.Text, a => a.B))
                            .TrackThisType <B>(t => t.IncludeProperties(b => b.Text, b => b.C))
                            .TrackThisType <C>(t => t.IncludeProperties(c => c.Text, c => c.ListOfD))
                            .TrackThisType <D>(t => t.IncludeProperty(d => d.Text))
                            .TrackThisType <E>(t => t.IncludeProperties(e => e.Text, e => e.Number))
                            .TrackThisType <Customer>(t => t.IncludeProperty(c => c.ContactInfo))
                            .TrackThisType <Contact>(t => t.IncludeProperty(c => c.Name))
                            .TrackThisType <EnhancedContact>(t => t.IncludeProperty(c => c.Default))
                            .TrackThisType <ClassWithReadOnlyPropertyThrowingException>()
                            .TrackThisType <ClassSettingPropertiesDuringConstructionTime>(t => t.IncludeProperty(c => c.Text));

            TrackableObjectFactory = Configuration.CreateTrackableObjectFactory();
        }
Esempio n. 12
0
        public void ConfiguresWithAttributesOnly()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

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

            IList <Type> trackables = config.TrackableTypes.Select(t => t.Type).ToList();

            Assert.IsTrue(config.TrackableTypes.Count > 0);
            Assert.IsTrue(trackables.Contains(typeof(AllProperties)));
            Assert.IsTrue(trackables.Contains(typeof(AllPropertiesExceptingNonTrackable)));
            Assert.IsTrue(trackables.Contains(typeof(TwoPropertiesOneTrackable)));
            Assert.IsFalse(trackables.Contains(typeof(NoAttributes)));
        }
Esempio n. 13
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);
        }
Esempio n. 14
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");
        }
Esempio n. 15
0
        public void CanReplaceCollectionChangeTrackingImplementation()
        {
            IObjectChangeTrackingConfiguration config = ObjectChangeTracking.CreateConfiguration();

            config.Collections.AddOrUpdateImplementation <ICollection <string>, List <string>, DefaultCollectionChangeInterceptor <string> >();
        }