public void SingletonCloneTest() { Container c = new Container(); SingletonInfo si = new SingletonInfo(() => new GuessableType()); c.AddInfo <GuessableType>(si); GuessableType outer = c.GetInstance <GuessableType>(); Container subc = c.Subcontainer(); GuessableType inner = subc.GetInstance <GuessableType>(); Assert.Same(inner, outer); }
public void ScopedDeepTest() { Container c = new Container(); ScopedInfo si = new ScopedInfo(() => new GuessableType()); c.AddInfo <GuessableType>(si); Container subc = c.Subcontainer(); GuessableType inner = subc.GetInstance <GuessableType>(); GuessableType outer = c.GetInstance <GuessableType>(); Assert.NotSame(inner, outer); }
public void GetInstancesTest() { Container c = new Container(); GuessableType gt = new GuessableType(); TransientGuessableType tgt = new TransientGuessableType(); c.AddInstance(gt); c.AddInstance <TransientGuessableType>(tgt); object[] arr = c.GetInstances <IGuessableType>().ToArray(); Assert.NotEmpty(arr); Assert.Equal(2, arr.Length); Assert.Contains(gt, arr); Assert.Contains(tgt, arr); }
public GuessableTypeWithNoInjectConstructor(GuessableType gt) { throw new NotImplementedException("What"); }
public GuessableTypeWithConstructor(GuessableType gt) { Assert.NotNull(gt); }
public void InjectMethod(GuessableType gt) { gotCalled = true; Assert.NotNull(gt); }