Exemple #1
0
            public override IEnumerable <IDataProvider> GetDataProviderList(DataProvidersConfigurationSection section, DataProvider[] dbProviders)
            {
                var ret = new List <IDataProvider>();

                ret.Add(new PartReadDataProviderStub());
                return(ret);
            }
            public static DataProvidersConfigurationSection CreateConfigSection()
            {
                var section = new DataProvidersConfigurationSection();

                section.Types.Add(new TypeElement()
                {
                    TypeName = typeof(LocalDataProviderStub).AssemblyQualifiedName
                });
                section.Types.Add(new TypeElement()
                {
                    TypeName = typeof(CustomExternalDataProviderStub).AssemblyQualifiedName
                });
                return(section);
            }
        public void GetDataProviderList_Valid_ExecutesFast(
            [ValueSource("GuidLargeCounts")] uint count)
        {
            var  facade = new GuidFacade(count);
            Type t      = typeof(GuidDataProvider);

            DataProvider[] dbProviders;

            Stopwatch watch = new Stopwatch();

            watch.Start();

            using (var dataContext = new CprBroker.Data.DataProviders.DataProvidersDataContext())
            {
                dbProviders = (from prov in dataContext.DataProviders
                               where prov.IsEnabled
                               orderby prov.Ordinal
                               select prov).ToArray();
            }


            DataProvidersConfigurationSection section = DataProvidersConfigurationSection.GetCurrent();


            bool missingDataProvidersExist;
            var  result = facade.CreateSubMethodRunStates(out missingDataProvidersExist);

            watch.Stop();


            var expectedDuration = TimeSpan.FromMilliseconds(1 * count);

            if (!GetDataProviderList_Valid_ExecutesFast_Called)
            {
                expectedDuration = TimeSpan.FromSeconds(3);
                GetDataProviderList_Valid_ExecutesFast_Called = true;
            }

            Console.WriteLine(string.Format("{0} ms for {1} entries - {2} ms/item", watch.Elapsed.TotalMilliseconds, count, watch.Elapsed.TotalMilliseconds / count));

            Assert.LessOrEqual(watch.Elapsed, expectedDuration);
        }