예제 #1
0
  // /*
  @Test
  public void singletonsSame() {
    try {
      c.RegisterType(Dummy.class, true);

      Dummy d1 = c.Resolve(Dummy.class);
      Dummy d2 = c.Resolve(Dummy.class);
      assertSame(d1, d2);
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
      fail();
    }
  }
예제 #2
0
 @Test
 public void genericPair() {
   try {
     c.RegisterType(Pair.class, false);
     Pair<String, Integer> p1 = c.Resolve(Pair.class);
     p1.setA("asdf");
     p1.setB(5);
     assertEquals("asdf", p1.a);
     assertEquals(5, (long) p1.b);
   } catch (Exception ex) {
     System.out.println(ex.getMessage());
     fail();
   }
 }
예제 #3
0
 @Test
 public void fromRegisteredAbstractClass() {
   try {
     c.RegisterType(AbstractBar.class, Bar.class, false);
     AbstractBar b = c.Resolve(AbstractBar.class);
     assertTrue(b instanceof Bar);
     b.doBar();
     Bar bb = (Bar) b;
     assertTrue(bb.isDone());
   } catch (Exception ex) {
     System.out.println(ex.getMessage());
     fail();
   }
 }
예제 #4
0
  @Test
  public void fromRegisteredInterface() {
    try {
      c.RegisterType(IFoo.class, Foo.class, false);
      IFoo f = c.Resolve(IFoo.class);
      c.RegisterType(IFoo.class, Foo2.class, false);
      IFoo f2 = c.Resolve(IFoo.class);

      assertTrue(f instanceof Foo);
      assertTrue(f2 instanceof Foo2);
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
      fail();
    }
  }