Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
 }
Exemplo n.º 6
0
 public void InjectMethod(GuessableType gt)
 {
     gotCalled = true;
     Assert.NotNull(gt);
 }