public void TestSingleton()
        {
            var factory = new SingletonInstanceFactory();
            var component1 = factory.GetInstance(typeof(Hoge));
            var component2 = factory.GetInstance(typeof(Hoge));

            Assert.AreSame(component1, component2);
        }
        public void TestDispose()
        {
            var testType = typeof(Hoge);
            var factory = new SingletonInstanceFactory();
            var component1 = factory.GetInstance(testType);

            factory.Dispose();
            var component2 = factory.GetInstance(testType);

            Assert.AreNotSame(component1, component2);
        }
 public void TestGetInstance()
 {
     var factory = new SingletonInstanceFactory();
     var component = factory.GetInstance(typeof(Hoge));
     Assert.IsNotNull(component);
     Assert.AreEqual(typeof(Hoge), component.GetType());
 }
        public void TestGetInstance_WithCallback()
        {
            var testObj = new CallBackClass();
            var factory = new SingletonInstanceFactory(testObj.GetHoge);
            var component = factory.GetInstance(typeof(Hoge));

            Assert.IsNotNull(component);
            Assert.AreEqual(typeof(Hoge), component.GetType());
        }
        public void TestSetValueFactory()
        {
            const char EXPECTED = 'a';
            var factory = new SingletonInstanceFactory(t => new string(new char[] { EXPECTED }));

            var component = factory.GetInstance(typeof(string));

            Assert.IsNotNull(component);
            Assert.AreEqual(EXPECTED.ToString(), component);
        }
 public void TestGetInstance_ArgNull()
 {
     var factory = new SingletonInstanceFactory();
     factory.GetInstance(null);
 }