Beispiel #1
0
 public void AssemblyRegisterTest()
 {
     using (var f = new IOCFactory("CommonClass.FactoryTestHelperAssembly")) {
         f.Init();
         Assert.IsTrue(f.Container.IsRegistered <FactoryTestHelperAssembly.II1>(), "检测IC1注册失败");
     }
 }
        public void DisposeTest()
        {
            var f = new IOCFactory();

            f.Init();
            Assert.IsNotNull(f.Container);
            f.Dispose();
            Assert.IsNull(f.Container);
        }
        public void InitTest()
        {
            var f = new IOCFactory();

            Assert.AreEqual(InitOptionEnum.BuildContainer, f.Option.InitOption);
            f.Init();
            Assert.IsNull(f.Builder);
            Assert.IsNotNull(f.Container);
            var c = f.Container.Resolve <ITestClass>();

            Assert.IsNotNull(c);
            f.Dispose();
        }
Beispiel #4
0
 public void EventTest()
 {
     //BeforeBuild测试
     using (var f = new IOCFactory()) {
         f.Init();
         Assert.IsFalse(f.Container.IsRegistered <ITest2>());
     }
     using (var f = new IOCFactory()) {
         f.BeforeBuild += (fa, c) => {
             c.Register(m => new TestClass2()).As <ITest2>();
         };
         f.Init();
         Assert.IsTrue(f.Container.IsRegistered <ITest2>());
     }
 }
Beispiel #5
0
        public void DisposeTest()
        {
            var f = new IOCFactory();

            f.Init();
            Assert.IsNotNull(f.Container);
            var o = f.Container.Resolve <ITestClass>();

            if (o is TestClass oc)
            {
                Assert.AreEqual(1, oc.Count);
            }
            f.Dispose();
            var ooo = new TestClass();

            Assert.AreEqual(1, ooo.Count);
        }