Example #1
0
        public void TheBindingShouldOnlyBeResolvedOnce()
        {
            var builder = kernel.Bind<IWeapon>().ToConstant(new Sword());
            var provider = new ResolveCountingProvider(builder.Binding.ProviderCallback);
            builder.Binding.ProviderCallback = ctx => provider.Callback(ctx);

            kernel.Get<IWeapon>();
            kernel.Get<IWeapon>();

            provider.Count.Should().Be(1);
        }
Example #2
0
        public void TheBindingShouldOnlyBeResolvedOnce()
        {
            var builder  = kernel.Bind <IWeapon>().ToConstant(new Sword());
            var provider = new ResolveCountingProvider(builder.BindingConfiguration.ProviderCallback);

            builder.BindingConfiguration.ProviderCallback = ctx => provider.Callback(ctx);


            kernel.Get <IWeapon>();
            kernel.Get <IWeapon>();

            provider.Count.Should().Be(1);
        }