public void TestCreateCachedObjectReturnsSameInstance() { var random = MagicIOC.Get <Random>(CachePolicy.Cached); var random2 = MagicIOC.Get <Random>(CachePolicy.Cached); Assert.That(random, Is.SameAs(random2)); }
public void TestCreateInterfaceMultipleTimesReturnsSameImplementation() { var impl = MagicIOC.Get <IImplemented>(); var impl2 = MagicIOC.Get <IImplemented>(); Assert.That(impl, Is.SameAs(impl2)); }
public void TestCreateClassTwiceUsesSameObjectAsParameters() { var foo1 = MagicIOC.Get <Foo>(); var foo2 = MagicIOC.Get <Foo>(); Assert.That(foo1.Bar, Is.SameAs(foo2.Bar)); }
public void TestCreateClassTwiceReturnsSameObject() { var foo1 = MagicIOC.Get <Foo>(); var foo2 = MagicIOC.Get <Foo>(); Assert.That(foo1, Is.SameAs(foo2)); }
public void TestCreateTwoUncachedObjectsReturnsDifferentInstance() { var random = MagicIOC.Get <Random>(CachePolicy.Cached); var random2 = MagicIOC.Get <Random>(CachePolicy.New); Assert.That(random, Is.Not.SameAs(random2)); }
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)); }
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)); }
public void TestCreateInterfaceWithImplementationReturnsImplementation() { var impl = MagicIOC.Get <IImplemented>(); Assert.That(impl, Is.InstanceOf <Implemented>()); }
public void TestCreateInterfaceWithNoSatisfiableDependenciesThrowsException() { Assert.Throws <ArgumentException>(() => MagicIOC.Get <IUnresolvable>()); }
public void TestCreateObjectWithParameterlessConstructor() { var random = MagicIOC.Get <Random>(); Assert.That(random, Is.InstanceOf <Random>()); }
public void TestCreateAbstractClassThrowsException() { Assert.Throws <ArgumentException>(() => MagicIOC.Get <Abstract>()); }
public void TestCreateObjectWithUnsatisfiableConstructorParametersThrowsException() { Assert.Throws <ArgumentException>(() => MagicIOC.Get <DependsOnInterface>()); }
public void TestCreateObjectWithNoConstructorsThrowsException() { Assert.Throws <ArgumentException>(() => MagicIOC.Get <CantCreate>()); }
public void TestValidParametersPassedToConstructor() { var foo = MagicIOC.Get <Foo>(); Assert.That(foo.Bar, Is.InstanceOf <Bar>()); }
public void TestCreateInterfaceDependentOnOtherInterfacesReturnsImplementation() { var foo = MagicIOC.Get <IFoo>(); Assert.That(foo, Is.InstanceOf <Foo>()); }
public void TestCreateInterfaceWithNoImplementationThrowsException() { Assert.Throws <ArgumentException>(() => MagicIOC.Get <INotImplemented>()); }
public void TestCreateClassThatDependsOnAnotherClass() { var foo = MagicIOC.Get <Foo>(); Assert.That(foo, Is.InstanceOf <Foo>()); }