public void IOCFactoryTest() { //无参构造函数测试 var f = new IOCFactory(); Assert.IsNotNull(f.Assemblies); Assert.AreEqual(0, f.Assemblies.Length); Assert.IsNull(f.Container); Assert.IsNull(f.Builder); f.Dispose(); //操作选项传递测试 var op = new FactoryOption(); f = new IOCFactory(op, this.GetType().Assembly); Assert.IsNotNull(f.Assemblies); Assert.AreEqual(op, f.Option); Assert.IsNull(f.Container); Assert.IsNull(f.Builder); f.Dispose(); //测试无任何操作 op = new FactoryOption { InitOption = InitOptionEnum.None }; f = new IOCFactory(op, this.GetType().Assembly); Assert.IsNotNull(f.Assemblies); Assert.AreEqual(op, f.Option); Assert.IsNull(f.Container); Assert.IsNull(f.Builder); f.Dispose(); }
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(); }
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); }