예제 #1
0
        public void TestCreateCachedObjectReturnsSameInstance()
        {
            var random  = MagicIOC.Get <Random>(CachePolicy.Cached);
            var random2 = MagicIOC.Get <Random>(CachePolicy.Cached);

            Assert.That(random, Is.SameAs(random2));
        }
예제 #2
0
        public void TestCreateInterfaceMultipleTimesReturnsSameImplementation()
        {
            var impl  = MagicIOC.Get <IImplemented>();
            var impl2 = MagicIOC.Get <IImplemented>();

            Assert.That(impl, Is.SameAs(impl2));
        }
예제 #3
0
        public void TestCreateClassTwiceUsesSameObjectAsParameters()
        {
            var foo1 = MagicIOC.Get <Foo>();
            var foo2 = MagicIOC.Get <Foo>();

            Assert.That(foo1.Bar, Is.SameAs(foo2.Bar));
        }
예제 #4
0
        public void TestCreateClassTwiceReturnsSameObject()
        {
            var foo1 = MagicIOC.Get <Foo>();
            var foo2 = MagicIOC.Get <Foo>();

            Assert.That(foo1, Is.SameAs(foo2));
        }
예제 #5
0
        public void TestCreateTwoUncachedObjectsReturnsDifferentInstance()
        {
            var random  = MagicIOC.Get <Random>(CachePolicy.Cached);
            var random2 = MagicIOC.Get <Random>(CachePolicy.New);

            Assert.That(random, Is.Not.SameAs(random2));
        }
예제 #6
0
        public void TestCreateUncachedObjectUsesCachedParameters()
        {
            var foo1 = MagicIOC.Get <Foo>(CachePolicy.New);
            var foo2 = MagicIOC.Get <Foo>(CachePolicy.New);

            Assert.That(foo1, Is.Not.SameAs(foo2));
            Assert.That(foo1.Bar, Is.SameAs(foo2.Bar));
        }
예제 #7
0
        public void TestCreateCachedObjectAfterCreatingUncachedObjectReturnsDifferentCachedInstance()
        {
            var random  = MagicIOC.Get <Random>(CachePolicy.New);
            var random2 = MagicIOC.Get <Random>(CachePolicy.Cached);
            var random3 = MagicIOC.Get <Random>(CachePolicy.Cached);

            Assert.That(random, Is.Not.SameAs(random2));
            Assert.That(random2, Is.SameAs(random3));
        }
예제 #8
0
        public void TestCreateInterfaceWithImplementationReturnsImplementation()
        {
            var impl = MagicIOC.Get <IImplemented>();

            Assert.That(impl, Is.InstanceOf <Implemented>());
        }
예제 #9
0
 public void TestCreateInterfaceWithNoSatisfiableDependenciesThrowsException()
 {
     Assert.Throws <ArgumentException>(() => MagicIOC.Get <IUnresolvable>());
 }
예제 #10
0
        public void TestCreateObjectWithParameterlessConstructor()
        {
            var random = MagicIOC.Get <Random>();

            Assert.That(random, Is.InstanceOf <Random>());
        }
예제 #11
0
 public void TestCreateAbstractClassThrowsException()
 {
     Assert.Throws <ArgumentException>(() => MagicIOC.Get <Abstract>());
 }
예제 #12
0
 public void TestCreateObjectWithUnsatisfiableConstructorParametersThrowsException()
 {
     Assert.Throws <ArgumentException>(() => MagicIOC.Get <DependsOnInterface>());
 }
예제 #13
0
 public void TestCreateObjectWithNoConstructorsThrowsException()
 {
     Assert.Throws <ArgumentException>(() => MagicIOC.Get <CantCreate>());
 }
예제 #14
0
        public void TestValidParametersPassedToConstructor()
        {
            var foo = MagicIOC.Get <Foo>();

            Assert.That(foo.Bar, Is.InstanceOf <Bar>());
        }
예제 #15
0
        public void TestCreateInterfaceDependentOnOtherInterfacesReturnsImplementation()
        {
            var foo = MagicIOC.Get <IFoo>();

            Assert.That(foo, Is.InstanceOf <Foo>());
        }
예제 #16
0
 public void TestCreateInterfaceWithNoImplementationThrowsException()
 {
     Assert.Throws <ArgumentException>(() => MagicIOC.Get <INotImplemented>());
 }
예제 #17
0
        public void TestCreateClassThatDependsOnAnotherClass()
        {
            var foo = MagicIOC.Get <Foo>();

            Assert.That(foo, Is.InstanceOf <Foo>());
        }