示例#1
0
        public void Factory_InstanceFactory_Same()
        {
            Factory.RemoveAllInjectors();
            var instance = new DefaultImplementation {
                Value = 123
            };

            Factory.AddInjector(new InstanceInjector <DefaultImplementation>(instance));
            var res = Factory.Get <DefaultImplementation>();

            Assert.Same(res, instance);
            Assert.Equal(res, instance);
        }
示例#2
0
        public void Factory_FunctionFactory_NotSame()
        {
            Factory.RemoveAllInjectors();
            var instance = new DefaultImplementation {
                Value = 123
            };

            Factory.AddInjector(new FunctionInjector <DefaultImplementation>(() => new DefaultImplementation {
                Value = 123
            }));
            var res = Factory.Get <DefaultImplementation>();

            Assert.NotSame(res, instance);
            Assert.Equal(res, instance);
        }