public void testExplicitGeneratorPrecedence() { var builder = new Konstruktor(); builder.forInterface<IDummy>().generate(s => new Implementation()); builder.forInterface<IDummy>().instantiate<Implementation2>(); using (var scope = builder.beginScope()) { var dummy = scope.resolve<IDummy>(); Assert.AreEqual(typeof(Implementation), dummy.GetType()); } }
public void testExplicitGeneratorPrecedence() { var builder = new Konstruktor(); builder.forInterface <IDummy>().generate(s => new Implementation()); builder.forInterface <IDummy>().instantiate <Implementation2>(); using (var scope = builder.beginScope()) { var dummy = scope.resolve <IDummy>(); Assert.AreEqual(typeof(Implementation), dummy.GetType()); } }
public void testImplementationSecondaryRegistered() { var builder = new Konstruktor(); builder.forInterface<IDummy>().instantiate<Implementation>(); builder.forInterface<ISecondary>().instantiate<Implementation>(); using (var scope = builder.beginScope()) { var dummy = scope.resolve<IDummy>(); var dummy2 = scope.resolve<ISecondary>(); Assert.True(ReferenceEquals(dummy, dummy2)); } }
public void testImplementationSecondaryRegistered() { var builder = new Konstruktor(); builder.forInterface <IDummy>().instantiate <Implementation>(); builder.forInterface <ISecondary>().instantiate <Implementation>(); using (var scope = builder.beginScope()) { var dummy = scope.resolve <IDummy>(); var dummy2 = scope.resolve <ISecondary>(); Assert.True(ReferenceEquals(dummy, dummy2)); } }
public static void mapInterface() { var b = new Konstruktor(); b.forInterface<IInterface>().instantiate<Implementation>(); using (var s = b.beginScope()) { var implementation = s.resolve<IInterface>(); Assert.AreEqual(typeof(Implementation), implementation.GetType()); } }
public static void mapInterface() { var b = new Konstruktor(); b.forInterface <IInterface>().instantiate <Implementation>(); using (var s = b.beginScope()) { var implementation = s.resolve <IInterface>(); Assert.AreEqual(typeof(Implementation), implementation.GetType()); } }
public void testConcrete() { var builder = new Konstruktor(); builder.forInterface<IDummy>().instantiate<Implementation>(); using (var scope = builder.beginScope()) { var dummy = scope.resolve<IDummy>(); Debug.Assert(dummy.GetType() == typeof(Implementation)); var dummy2 = scope.resolve<IDummy>(); Debug.Assert(ReferenceEquals(dummy, dummy2)); } }
public void testConcrete() { var builder = new Konstruktor(); builder.forInterface <IDummy>().instantiate <Implementation>(); using (var scope = builder.beginScope()) { var dummy = scope.resolve <IDummy>(); Debug.Assert(dummy.GetType() == typeof(Implementation)); var dummy2 = scope.resolve <IDummy>(); Debug.Assert(ReferenceEquals(dummy, dummy2)); } }
public void interfaceDispose() { _disposed.Clear(); var b = new Konstruktor(); b.forInterface<IB>().instantiate<B>(); using (var scope = b.beginScope()) { // both should be the same object, but // dispose should be only called on A's instance (once). var b1 = scope.resolve<IB>(); var b2 = scope.resolve<B>(); Assert.AreSame(b1, b2); } Assert.AreEqual(1, _disposed.Count); Assert.AreEqual(typeof(B), _disposed[0].GetType()); }
public void interfaceDispose() { _disposed.Clear(); var b = new Konstruktor(); b.forInterface <IB>().instantiate <B>(); using (var scope = b.beginScope()) { // both should be the same object, but // dispose should be only called on A's instance (once). var b1 = scope.resolve <IB>(); var b2 = scope.resolve <B>(); Assert.AreSame(b1, b2); } Assert.AreEqual(1, _disposed.Count); Assert.AreEqual(typeof(B), _disposed[0].GetType()); }