public override void Verify(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsCombined)
            {
                return;
            }

            if (Combined1.Instances != this.LoopCount ||
                Combined2.Instances != this.LoopCount ||
                Combined3.Instances != this.LoopCount)
            {
                throw new Exception(string.Format("Combined count must be {0}", this.LoopCount));
            }

            if (Transient1.Instances != this.LoopCount ||
                Transient2.Instances != this.LoopCount ||
                Transient3.Instances != this.LoopCount)
            {
                throw new Exception(string.Format("Transient count must be {0}", this.LoopCount));
            }

            if (Singleton1.Instances > 1 || Singleton2.Instances > 1 || Singleton2.Instances > 1)
            {
                throw new Exception("Singleton instance count must be 1. Container: " + container.Name);
            }
        }
Exemplo n.º 2
0
 public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
 {
     return(new BenchmarkResult(this, container)
     {
         Time = base.Measure <ISingleton1, ISingleton2, ISingleton3>(container)
     });
 }
Exemplo n.º 3
0
        public override void Warmup(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsChildContainer)
            {
                return;
            }

            using (var childContainer = container.CreateChildContainerAdapter())
            {
                childContainer.Prepare();

                ICombined1 scopedCombined1 = (ICombined1)childContainer.Resolve(typeof(ICombined1));
                ICombined2 scopedCombined2 = (ICombined2)childContainer.Resolve(typeof(ICombined2));
                ICombined3 scopedCombined3 = (ICombined3)childContainer.Resolve(typeof(ICombined3));

                if (scopedCombined1 == null || scopedCombined2 == null || scopedCombined3 == null)
                {
                    throw new Exception(string.Format("Child Container {0} could not create type {1}", container.Name, typeof(ICombined1)));
                }

                if (!(scopedCombined1 is ScopedCombined1) || !(scopedCombined2 is ScopedCombined2) ||
                    !(scopedCombined3 is ScopedCombined3))
                {
                    throw new Exception(string.Format(
                                            "Child Container {0} resolved type incorrectly should have been {1} but was {2}",
                                            container.Name,
                                            typeof(ICombined1),
                                            scopedCombined1.GetType()));
                }
            }

            ScopedCombined1.Instances = 0;
            ScopedCombined2.Instances = 0;
            ScopedCombined3.Instances = 0;
        }
Exemplo n.º 4
0
 public override void Verify(Adapters.IContainerAdapter container)
 {
     if (Singleton1.Instances != this.LoopCount)
     {
         throw new Exception(string.Format("Singleton1 count must be {0}", this.LoopCount));
     }
 }
 public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
 {
     return(new BenchmarkResult(this, container)
     {
         Time = base.Measure <ICombined1, ICombined2, ICombined3>(container)
     });
 }
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportsInterception)
            {
                BenchmarkBase.CollectMemory();

                var watch = new Stopwatch();

                watch.Start();

                for (int i = 0; i < BenchmarkBase.LoopCount; i++)
                {
                    var result1 = (ICalculator1)container.ResolveProxy(typeof(ICalculator1));
                    var result2 = (ICalculator2)container.ResolveProxy(typeof(ICalculator2));
                    var result3 = (ICalculator3)container.ResolveProxy(typeof(ICalculator3));

                    result1.Add(5, 10);
                    result2.Add(5, 10);
                    result3.Add(5, 10);
                }

                watch.Stop();

                result.Time = watch.ElapsedMilliseconds;
            }

            return(result);
        }
Exemplo n.º 7
0
 public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
 {
     return(new BenchmarkResult(this, container)
     {
         Time = base.Measure <ITransient1, ITransient2, ITransient3>(container)
     });
 }
Exemplo n.º 8
0
 public override void Verify(Adapters.IContainerAdapter container)
 {
     if (Singleton1.Instances > 1 || Singleton2.Instances > 1 || Singleton2.Instances > 1)
     {
         throw new Exception("Singleton instance count must be 1. Container: " + container.Name);
     }
 }
Exemplo n.º 9
0
 public override void Verify(Adapters.IContainerAdapter container)
 {
     if (Transient1.Instances != Benchmark.LoopCount ||
         Transient2.Instances != Benchmark.LoopCount ||
         Transient3.Instances != Benchmark.LoopCount)
     {
         throw new Exception(string.Format("Transient count must be {0}", Benchmark.LoopCount));
     }
 }
 public override void Verify(Adapters.IContainerAdapter container)
 {
     if (Complex1.Instances != Benchmark.LoopCount ||
         Complex2.Instances != Benchmark.LoopCount ||
         Complex3.Instances != Benchmark.LoopCount)
     {
         throw new Exception(string.Format("Complex count must be {0}", Benchmark.LoopCount));
     }
 }
Exemplo n.º 11
0
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportGeneric)
            {
                result.Time = base.Measure <ImportGeneric <int>, ImportGeneric <float>, ImportGeneric <object> >(container);
            }

            return(result);
        }
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportsMultiple)
            {
                result.Time = base.Measure <ImportMultiple1, ImportMultiple2, ImportMultiple3>(container);
            }

            return(result);
        }
Exemplo n.º 13
0
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportsPropertyInjection)
            {
                result.Time = base.Measure <IComplexPropertyObject1, IComplexPropertyObject2, IComplexPropertyObject3>(container);
            }

            return(result);
        }
        public override BenchmarkResult Measure(Adapters.IContainerAdapter container)
        {
            var result = new BenchmarkResult(this, container);

            if (container.SupportsConditional)
            {
                result.Time = base.Measure <ImportConditionObject1, ImportConditionObject2, ImportConditionObject3>(container);
            }

            return(result);
        }
        public override void Verify(Adapters.IContainerAdapter container)
        {
            // Cauldron has an instance count of 0, which seems to be caused by the code generation
            if (container.GetType().Equals(typeof(CauldronContainerAdapter)) && Singleton1.Instances == 0)
            {
                return;
            }

            if (Singleton1.Instances != this.LoopCount)
            {
                throw new Exception(string.Format("Singleton1 count must be {0} but was {1}", this.LoopCount, Singleton1.Instances));
            }
        }
        public override void Verify(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsConditional)
            {
                return;
            }

            if (ImportConditionObject1.Instances != this.LoopCount ||
                ImportConditionObject2.Instances != this.LoopCount ||
                ImportConditionObject3.Instances != this.LoopCount)
            {
                throw new Exception(string.Format("ImportConditionObject count must be {0}", this.LoopCount));
            }
        }
        public override void Verify(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsTransient)
            {
                return;
            }

            if (Transient1.Instances != this.LoopCount ||
                Transient2.Instances != this.LoopCount ||
                Transient3.Instances != this.LoopCount)
            {
                throw new Exception(string.Format("Transient count must be {0}", this.LoopCount));
            }
        }
Exemplo n.º 18
0
        public override void Verify(Adapters.IContainerAdapter container)
        {
            if (!container.SupportGeneric)
            {
                return;
            }

            if (ImportGeneric <int> .Instances != Benchmark.LoopCount ||
                ImportGeneric <float> .Instances != Benchmark.LoopCount ||
                ImportGeneric <object> .Instances != Benchmark.LoopCount)
            {
                throw new Exception(string.Format("ImportGeneric count must be {0}", Benchmark.LoopCount));
            }
        }
Exemplo n.º 19
0
        public override void Verify(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsPropertyInjection)
            {
                return;
            }

            if (ComplexPropertyObject1.Instances != BenchmarkBase.LoopCount ||
                ComplexPropertyObject2.Instances != BenchmarkBase.LoopCount ||
                ComplexPropertyObject3.Instances != BenchmarkBase.LoopCount)
            {
                throw new Exception(string.Format("ComplexPropertyObject count must be {0}", BenchmarkBase.LoopCount));
            }
        }
Exemplo n.º 20
0
        public override void Verify(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsChildContainer)
            {
                return;
            }

            if (ScopedCombined1.Instances != this.LoopCount ||
                ScopedCombined2.Instances != this.LoopCount ||
                ScopedCombined3.Instances != this.LoopCount)
            {
                throw new Exception(string.Format("ScopedCombined count must be {0}", this.LoopCount));
            }
        }
        public override void Verify(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsMultiple)
            {
                return;
            }

            if (ImportMultiple1.Instances != BenchmarkBase.LoopCount ||
                ImportMultiple2.Instances != BenchmarkBase.LoopCount ||
                ImportMultiple3.Instances != BenchmarkBase.LoopCount)
            {
                throw new Exception(string.Format("ImportMultiple count must be {0}", BenchmarkBase.LoopCount));
            }
        }
        public override void Verify(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsInterception)
            {
                return;
            }

            if (Calculator1.Instances != this.LoopCount ||
                Calculator2.Instances != this.LoopCount ||
                Calculator3.Instances != this.LoopCount)
            {
                throw new Exception(string.Format("Calculator count must be {0}", this.LoopCount));
            }
        }
Exemplo n.º 23
0
        public override void Warmup(Adapters.IContainerAdapter container)
        {
            var complex1 = (IComplex1)container.Resolve(typeof(IComplex1));
            var complex2 = (IComplex2)container.Resolve(typeof(IComplex2));
            var complex3 = (IComplex3)container.Resolve(typeof(IComplex3));

            if (complex1 == null || complex2 == null || complex3 == null)
            {
                throw new Exception(string.Format("Container {0} could not create type {1}", container.Name, typeof(IComplex1)));
            }

            Complex1.Instances = 0;
            Complex2.Instances = 0;
            Complex3.Instances = 0;
        }
Exemplo n.º 24
0
        public override void Warmup(Adapters.IContainerAdapter container)
        {
            var transient1 = (ITransient1)container.Resolve(typeof(ITransient1));
            var transient2 = (ITransient2)container.Resolve(typeof(ITransient2));
            var transient3 = (ITransient3)container.Resolve(typeof(ITransient3));

            if (transient1 == null || transient2 == null || transient3 == null)
            {
                throw new Exception(string.Format("Container {0} could not create type {1}", container.Name, typeof(ITransient1)));
            }

            Transient1.Instances = 0;
            Transient2.Instances = 0;
            Transient3.Instances = 0;
        }
Exemplo n.º 25
0
        public override void Warmup(Adapters.IContainerAdapter container)
        {
            Singleton1.Instances = 0;
            Singleton2.Instances = 0;
            Singleton3.Instances = 0;

            var singleton1 = (ISingleton1)container.Resolve(typeof(ISingleton1));
            var singleton2 = (ISingleton2)container.Resolve(typeof(ISingleton2));
            var singleton3 = (ISingleton3)container.Resolve(typeof(ISingleton3));

            if (singleton1 == null || singleton2 == null || singleton3 == null)
            {
                throw new Exception(string.Format("Container {0} could not create type {1}", container.Name, typeof(ISingleton1)));
            }
        }
        public override void Warmup(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsMultiple)
            {
                return;
            }

            var importMultiple1 = (ImportMultiple1)container.Resolve(typeof(ImportMultiple1));
            var importMultiple2 = (ImportMultiple2)container.Resolve(typeof(ImportMultiple2));
            var importMultiple3 = (ImportMultiple3)container.Resolve(typeof(ImportMultiple3));

            if (importMultiple1 == null || importMultiple2 == null || importMultiple3 == null)
            {
                throw new Exception(string.Format("Container {0} could not create type {1}", container.Name, typeof(ImportMultiple1)));
            }

            ImportMultiple1.Instances = 0;
            ImportMultiple2.Instances = 0;
            ImportMultiple3.Instances = 0;
        }
Exemplo n.º 27
0
        public override void Warmup(Adapters.IContainerAdapter container)
        {
            if (!container.SupportGeneric)
            {
                return;
            }

            var generic1 = (ImportGeneric <int>)container.Resolve(typeof(ImportGeneric <int>));
            var generic2 = (ImportGeneric <float>)container.Resolve(typeof(ImportGeneric <float>));
            var generic3 = (ImportGeneric <object>)container.Resolve(typeof(ImportGeneric <object>));

            if (generic1 == null || generic2 == null || generic3 == null)
            {
                throw new Exception(string.Format("Container {0} could not create type {1}", container.Name, typeof(ImportGeneric <>)));
            }

            ImportGeneric <int> .Instances    = 0;
            ImportGeneric <float> .Instances  = 0;
            ImportGeneric <object> .Instances = 0;
        }
        public override void Warmup(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsInterception)
            {
                return;
            }

            var calculator1 = (ICalculator1)container.ResolveProxy(typeof(ICalculator1));

            calculator1.Add(1, 2);
            var calculator2 = (ICalculator2)container.ResolveProxy(typeof(ICalculator2));

            calculator2.Add(1, 2);
            var calculator3 = (ICalculator3)container.ResolveProxy(typeof(ICalculator3));

            calculator3.Add(1, 2);

            Calculator1.Instances = 0;
            Calculator2.Instances = 0;
            Calculator3.Instances = 0;
        }
Exemplo n.º 29
0
        public override void Warmup(Adapters.IContainerAdapter container)
        {
            if (!container.SupportsPropertyInjection)
            {
                return;
            }

            var complex1 = (IComplexPropertyObject1)container.Resolve(typeof(IComplexPropertyObject1));
            var complex2 = (IComplexPropertyObject2)container.Resolve(typeof(IComplexPropertyObject2));
            var complex3 = (IComplexPropertyObject3)container.Resolve(typeof(IComplexPropertyObject3));

            if (complex1 == null || complex2 == null || complex3 == null)
            {
                throw new Exception(string.Format("Container {0} could not create type {1}", container.Name, typeof(IComplexPropertyObject1)));
            }

            complex1.Verify(container.Name);
            complex1.Verify(container.Name);
            complex1.Verify(container.Name);

            ComplexPropertyObject1.Instances = 0;
            ComplexPropertyObject2.Instances = 0;
            ComplexPropertyObject3.Instances = 0;
        }
Exemplo n.º 30
0
 public ContainerAdapterInfo(Adapters.IContainerAdapter container)
 {
     this.Name    = container.Name;
     this.Url     = container.Url;
     this.Version = container.Version;
 }