示例#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>());
        }