Ejemplo n.º 1
0
        public void DelegateFiveArg_Create_Instance()
        {
            var container = new DependencyInjectionContainer();

            container.Configure(co => co.Export(typeof(FiveDependencyService <, , , ,>)).As(typeof(IFiveDependencyService <, , , ,>)));

            var func = container.Locate <DependentService>();

            Assert.NotNull(func);

            var a = new SimpleObjectA();
            var b = new SimpleObjectB();
            var c = new SimpleObjectC();
            var d = new SimpleObjectD();
            var e = new SimpleObjectE();

            var instance = func(a, b, c, d, e);

            Assert.NotNull(instance);
            Assert.Same(a, instance.Dependency1);
            Assert.Same(b, instance.Dependency2);
            Assert.Same(c, instance.Dependency3);
            Assert.Same(d, instance.Dependency4);
            Assert.Same(e, instance.Dependency5);
        }
Ejemplo n.º 2
0
        public void ReturnsBasicObject()
        {
            var primitiveA = new SimpleObjectA();
            var primitiveB = _mapper.Map <SimpleObjectB>(primitiveA);

            Assert.IsNotNull(primitiveB);
            Assert.AreEqual(primitiveB.GetType(), typeof(SimpleObjectB));
        }
Ejemplo n.º 3
0
        public void WithValue()
        {
            var primitiveA = new SimpleObjectA {
                Primitive = 1
            };
            var primitiveB = _mapper.Map <SimpleObjectB>(primitiveA);

            Assert.AreEqual(primitiveA.Primitive, primitiveB.Primitive);

            primitiveA.Primitive = 13;
            var primitiveC = _mapper.Map <SimpleObjectB>(primitiveA);

            Assert.AreEqual(primitiveA.Primitive, primitiveC.Primitive);
            Assert.AreNotEqual(primitiveB.Primitive, primitiveC.Primitive);
        }
Ejemplo n.º 4
0
        public void PropMismatch()
        {
            var hasProps = new ObjectA {
                Blah = "blah", Meh = 10f, Primitive = 12, SomeOther = "other", YetAnother = "yet"
            };
            var primitiveA = _mapper.Map <SimpleObjectA>(hasProps);

            Assert.AreEqual(hasProps.Primitive, primitiveA.Primitive);

            primitiveA = new SimpleObjectA {
                Primitive = 76
            };
            hasProps = _mapper.Map <ObjectA>(primitiveA);
            Assert.AreEqual(primitiveA.Primitive, hasProps.Primitive);
            Assert.AreEqual(default(float), hasProps.Meh);
            Assert.AreEqual(default(string), hasProps.Blah);
        }
Ejemplo n.º 5
0
        public void ThreeArgDelegate_Create_Instance()
        {
            var container = new DependencyInjectionContainer();

            container.Configure(c => c.Export(typeof(ThreeDependencyService <, ,>)).As(typeof(IThreeDependencyService <, ,>)));

            var func = container.Locate <DependentDelegate>();

            var basicService    = new BasicService();
            var simpleObject    = new SimpleObjectA();
            var multipleService = new MultipleService1();

            var instance = func(basicService, simpleObject, multipleService);

            Assert.NotNull(instance);
            Assert.Same(basicService, instance.Dependency1);
            Assert.Same(simpleObject, instance.Dependency2);
            Assert.Same(multipleService, instance.Dependency3);
        }