コード例 #1
0
 public void RegisterSingletonObject()
 {
     ObjectContainer locator = new ObjectContainer();
     locator.RegisterSingleton<object>(c => { return new object(); });
     var result = locator.Create<object>();
     Assert.IsAssignableFrom<object>(result);
     var result2 = locator.Create<object>();
     Assert.AreSame(result, result2);
 }
コード例 #2
0
 public void ToString_NoParameters_ReturnsDescription()
 {
     ObjectContainer locator = new ObjectContainer();
     locator.RegisterSingleton<object>(c => { return new object(); });
     var log = new Mock<ILogger>();
     locator.Register<ILogger>(c => { return log.Object; });
     locator.Configuration["Object"]=new object();
     var result = locator.ToString();
     Assert.IsInstanceOf<string>(result);
     //Console.WriteLine(result);
 }