Exemple #1
0
 public void This()
 {
     _iocContainer.Resolve <ICompositionRoot>();
     _iocContainer.Resolve <ICompositionRoot>();
     _iocContainer.Resolve <ICompositionRoot>();
     _iocContainer.Resolve <ICompositionRoot>();
     _iocContainer.Resolve <ICompositionRoot>();
     _iocContainer.Resolve <ICompositionRoot>();
     _iocContainer.Resolve <ICompositionRoot>();
     _iocContainer.Resolve <ICompositionRoot>();
     _iocContainer.Resolve <ICompositionRoot>();
     _iocContainer.Resolve <ICompositionRoot>();
 }
Exemple #2
0
        public void Initialize()
        {
            DebugOnlySession.Attach();
            //_tray = (TaskbarIcon)Application.Current.Resources["SysTray"];
            _container = new IoC.Container();
            var tray = _container.Resolve <AppTrayView>();

            tray.LoadContent();

            if (_rules.UseLastConnection)
            {
                var coreDataDriveService = _container.Resolve <ICoreDataDriveService>();
                coreDataDriveService.Restore();
            }
        }
Exemple #3
0
 public void This()
 {
     for (var i = 0; i < Series; i++)
     {
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
         _iocContainer.Resolve <IServiceRoot>().DoSomething();
     }
 }
Exemple #4
0
        public void UnRegister_Succeeds()
        {
            IContainer container = new IoC.Container();

            container.Register <ITestClass4, TestClass4>();

            var actual = container.Resolve(typeof(ITestClass4)) as ITestClass4;

            Assert.NotNull(actual);

            container.UnRegister <ITestClass4>();

            Exception ex = Assert.Throws <TypeNotRegisteredException>(() => container.Resolve(typeof(ITestClass4)));

            Assert.NotNull(ex);
            Assert.Equal("Type 'IoC.Test.ContainerTests+ITestClass4' not registered with Container instance.", ex.Message);
        }
Exemple #5
0
        public void Register_LifeCycleTypeTransientSucceedsTest()
        {
            IContainer container = new IoC.Container();

            container.Register <ITestClass4, TestClass4>();
            container.Register <ITestClass2, TestClass2>(LifeCycleType.Transient);
            container.Register <ITestClass3, TestClass3>(LifeCycleType.Transient);
            container.Register <ITestClass, TestClass>(LifeCycleType.Transient);

            var actual1 = container.Resolve(typeof(ITestClass)) as ITestClass;
            var actual2 = container.Resolve(typeof(ITestClass)) as ITestClass;

            Assert.NotNull(actual1);
            Assert.NotNull(actual2);
            Assert.NotEqual(actual1, actual2);
            Assert.NotEqual(actual1.TestClassProp2, actual2.TestClassProp2);
            Assert.NotEqual(actual1.TestClassProp3, actual2.TestClassProp3);
        }
Exemple #6
0
        public void Resolve_ThrowsTypeNotRegisteredExceptionTest()
        {
            IContainer container = new IoC.Container();

            container.Register <ITestClass2, TestClass2>();
            // leave ITestClass3 out for test
            container.Register <ITestClass4, TestClass4>();
            container.Register <ITestClass, TestClass>();

            Exception actual = Assert.Throws <TypeNotRegisteredException>(
                () => container.Resolve(typeof(ITestClass)));

            Assert.NotNull(actual);
            Assert.Equal("Type 'IoC.Test.ContainerTests+ITestClass3' not registered with Container instance.", actual.Message);
        }
Exemple #7
0
        public void Resolve_SucceedsTest()
        {
            IContainer container = new IoC.Container();

            container.Register <ITestClass2, TestClass2>(LifeCycleType.Singleton);
            container.Register <ITestClass3, TestClass3>();
            container.Register <ITestClass4, TestClass4>();
            container.Register <ITestClass, TestClass>(LifeCycleType.Transient);

            var actual = container.Resolve(typeof(ITestClass)) as ITestClass;

            Assert.NotNull(actual);
            Assert.NotNull(actual.TestClassProp2);
            Assert.NotNull(actual.TestClassProp3);
            Assert.NotNull(actual.TestClassProp3.TestClassProp4);
            Assert.Equal("TestClass2", actual.GetMyString());
        }