コード例 #1
0
        public void ResoveConcreteClass()
        {
            // Given
            DIContainer container = new DIContainer();

            container.Register <ConcreteB, ConcreteB>();

            // When
            ConcreteB obj = container.Resolve <ConcreteB>();

            // Then
            Assert.IsNotNull(obj);
            Assert.AreEqual(0, obj.IntValue);
            Assert.IsNull(obj.StrValue);
            Assert.AreEqual(MyEnum.A, obj.EnumValue);
        }
コード例 #2
0
        public void ResoveTwiceTest()
        {
            // Given
            DIContainer container = new DIContainer();

            container.Register <ITestInterface, A>();

            // When
            var       objC1 = container.Resolve <C>();
            var       objC2 = container.Resolve <C>();
            ConcreteB obj1  = container.Resolve <ConcreteB>();
            ConcreteB obj2  = container.Resolve <ConcreteB>();

            // Then
            Assert.IsNotNull(objC1);
            Assert.AreEqual(objC1, objC2);

            Assert.IsNotNull(obj1);
            Assert.AreEqual(obj1, obj2);
        }
コード例 #3
0
 public D(ITestInterface test, ConcreteB b, int v) : base(test, b)
 {
     m_value = v;
 }
コード例 #4
0
 public C(ITestInterface test, ConcreteB b)
 {
     TestObject      = test;
     ConcreteBObject = b;
 }