Beispiel #1
0
        public void ResolveJunkFood()
        {
            var builder = new ContainerBuilder();

            builder.Register(c =>
                             JunkFoodFactory.Create("chicken meal"));

            var meal = builder.Build().Resolve <IMeal>();

            var junk = Assert.IsAssignableFrom <JunkFood>(meal);

            Assert.Equal("chicken meal", junk.Name);
        }
Beispiel #2
0
        public void ResolveJunkFood()
        {
            var container = new UnityContainer();

            container.RegisterType <IMeal, JunkFood>(
                new InjectionFactory(
                    c => JunkFoodFactory.Create("chicken meal")));

            var meal = container.Resolve <IMeal>();

            var junk = Assert.IsAssignableFrom <JunkFood>(meal);

            Assert.Equal("chicken meal", junk.Name);
        }
Beispiel #3
0
        public void ResolveJunkFood()
        {
            var container = new WindsorContainer();

            container.Register(Component
                               .For <IMeal>()
                               .UsingFactoryMethod(() =>
                                                   JunkFoodFactory.Create("chicken meal")));

            var meal = container.Resolve <IMeal>();

            var junk = Assert.IsAssignableFrom <JunkFood>(meal);

            Assert.Equal("chicken meal", junk.Name);
        }
Beispiel #4
0
        public void ResolveJunkFood()
        {
            var container = new Container();

            container.Configure(r => r
                                .For <IMeal>()
                                .Use(() =>
                                     JunkFoodFactory.Create("chicken meal")));

            var meal = container.GetInstance <IMeal>();

            var junk = Assert.IsAssignableFrom <JunkFood>(meal);

            Assert.Equal("chicken meal", junk.Name);
        }
Beispiel #5
0
 public JunkFoodAdapter()
 {
     this.junk = JunkFoodFactory.Create("chicken meal");
 }