Example #1
0
        public void parses_the_field()
        {
            var settings = new SchemaMetadataSettings
            {
                Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Clarify", "Metadata", SchemaMetadataSettings.FileName)
            };

            var visitors = new List <IXElementVisitor> {
                new ParseTables(), new ParseFields()
            };
            var service  = new XElementService(visitors);
            var services = new InMemoryServiceLocator();

            services.Add <IXElementService>(service);
            services.Add <IXElementSerializer>(new XElementSerializer());

            var cache = new SchemaMetadataCache(settings, new NulloLogger(), service, services);

            // Other tables shouldn't exist but will never be null
            cache.MetadataFor("test").ShouldNotBeNull();

            var table = cache.MetadataFor("case");

            // Other fields shouldn't exist but will also never be null
            table.MetadataFor("test").ShouldNotBeNull();
            var field = table.MetadataFor("creation_time");

            field.IsDateOnlyField().ShouldBeTrue();
        }
Example #2
0
        public void race_condition()
        {
            var settings = new SchemaMetadataSettings
            {
                Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Clarify", "Metadata", SchemaMetadataSettings.FileName)
            };

            var visitors = new List <IXElementVisitor> {
                new ParseTables(), new ParseFields()
            };
            var service  = new XElementService(visitors);
            var services = new InMemoryServiceLocator();

            services.Add <IXElementService>(service);
            services.Add <IXElementSerializer>(new XElementSerializer());

            var cache = new SchemaMetadataCache(settings, new NulloLogger(), service, services);

            // Other tables shouldn't exist but will never be null
            cache.MetadataFor("test").ShouldNotBeNull();

            const string targetTable = "TEST_TABLE";
            var          actions     = new List <Action>();
            var          cleanups    = new List <Action>();

            for (var i = 0; i < 500; i++)
            {
                var thread = new Thread(() =>
                {
                    cache.MetadataFor("case1");
                    cache.MetadataFor("case1");
                    cache.MetadataFor(targetTable);
                    cache.MetadataFor(targetTable);
                    cache.MetadataFor(targetTable);
                    cache.MetadataFor(targetTable);
                });

                actions.Add(() =>
                {
                    Thread.Sleep(50);
                    thread.Start();
                });

                cleanups.Add(() => thread.Join());
            }

            Parallel.Invoke(actions.ToArray());

            cleanups.Each(callback => callback());

            cache.MetadataFor(targetTable).ShouldNotBeNull();
        }
Example #3
0
        private ModelMap.ModelMap parseMap()
        {
            var logger = new NulloLogger();

            Services.Add <ILogger>(logger);
            Services.Add <IObjectBuilder>(new ObjectBuilder());
            Services.Add <IFilterPolicyRegistry>(new FilterPolicyRegistry());
            Services.Add <IXElementSerializer>(new XElementSerializer(new MappingVariableExpander(new MappingVariableRegistry(new List <IMappingVariableSource>()), _services)));
            Services.Add <IMappingVariableExpander>(new MappingVariableExpander(new MappingVariableRegistry(new List <IMappingVariableSource>()), _services));

            var visitors       = Visitors();
            var elementService = new XElementService(visitors);

            var parser    = new HistoryMapParser(Services, elementService, logger);
            var overrides = new HistoryMapOverrideParser(parser, new ModelMapDiff(), new HistoryMapDiffOptions());
            var settings  = Services.GetInstance <HistorySettings>();

            Cache = new HistoryMapCache(parser, settings, overrides);

            return(Cache.Maps().First());
        }
        private ModelMap parseMap()
        {
            var logger   = new NulloLogger();
            var services = new InMemoryServiceLocator();

            services.Add <ILogger>(logger);
            services.Add <IObjectBuilder>(new ObjectBuilder());
            services.Add <IFilterPolicyRegistry>(new FilterPolicyRegistry());
            services.Add <IXElementSerializer>(new XElementSerializer(new MappingVariableExpander(new MappingVariableRegistry(new List <IMappingVariableSource>()), services)));
            services.Add <IMappingVariableExpander>(new MappingVariableExpander(new MappingVariableRegistry(new List <IMappingVariableSource>()), services));

            var visitors       = Visitors();
            var elementService = new XElementService(visitors);
            var parser         = new ModelMapParser(services, elementService, logger);
            var overrides      = new ModelMapOverrideParser(parser, new ModelMapDiff(), new ModelMapDiffOptions());
            var replacements   = new ModelMapReplacementParser(parser);

            var settings = new ModelMapSettings {
                Directory = _tempPath
            };
            var cache = new ModelMapCache(parser, overrides, replacements, settings);

            return(cache.Maps().Single());
        }