Beispiel #1
0
        public void Resolve_INIFile_ShouldResolveNewINIFileFromApplicationFolder()
        {
            //---------------Set up test pack-------------------
            var asmPath   = new Uri(typeof(WindsorBootstrapper).Assembly.CodeBase).LocalPath;
            var asmFolder = Path.GetDirectoryName(asmPath);
            var iniPath   = Path.Combine(asmFolder, Constants.CONFIG_FILE);

            using (new AutoDeleter(iniPath))
            {
                var iniFile  = new INIFile(iniPath);
                var expected = GetRandomInt(5, 55).ToString();
                iniFile["settings"]["RefreshIntervalInMinutes"] = expected;
                iniFile.Persist();
                var container = WindsorBootstrapper.Bootstrap();
                //---------------Assert Precondition----------------
                Assert.IsTrue(File.Exists(iniPath));

                //---------------Execute Test ----------------------
                var resolvedIni = container.Resolve <IINIFile>();
                var result      = resolvedIni["settings"]["RefreshIntervalInMinutes"];

                //---------------Test Result -----------------------
                Assert.AreEqual(expected, result);
            }
        }
        public void DefaultConstructor_ShouldUse_ContainerFrom_WindsorBootstrapper()
        {
            // obtuse proof: should resolve the same random INI file setting
            //---------------Set up test pack-------------------
            var asmPath   = new Uri(typeof(WindsorBootstrapper).Assembly.CodeBase).LocalPath;
            var asmFolder = Path.GetDirectoryName(asmPath);
            var iniPath   = Path.Combine(asmFolder, Constants.CONFIG_FILE);

            using (new AutoDeleter(iniPath))
            {
                var iniFile = new INIFile(iniPath);
                iniFile["settings"]["RefreshIntervalInMinutes"] = GetRandomInt(5, 55).ToString();
                iniFile.Persist();
                var referenceContainer = WindsorBootstrapper.Bootstrap();
                var sut = CreateDefault();
                //---------------Assert Precondition----------------
                Assert.IsTrue(File.Exists(iniPath));

                //---------------Execute Test ----------------------
                var resolvedIni = referenceContainer.Resolve <IINIFile>();
                var expected    = resolvedIni["settings"]["RefreshIntervalInMinutes"];
                var result      = sut.WindsorContainer.Resolve <IINIFile>()["settings"]["RefreshIntervalInMinutes"];

                //---------------Test Result -----------------------
                Assert.AreEqual(expected, result);
            }
        }
 public static IWindsorContainer Bootstrap()
 {
     var bootstrapper = new WindsorBootstrapper();
     var container = bootstrapper.Bootstrap();
     var controllerFactory = new WindsorControllerFactory(container.Kernel);
     ControllerBuilder.Current.SetControllerFactory(controllerFactory);
     return container;
 }
Beispiel #4
0
        public void  Container_ShouldResolveSingleton_SimpleLoggerFacade()
        {
            //---------------Set up test pack-------------------
            var container = WindsorBootstrapper.Bootstrap();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var result1 = container.Resolve <ISimpleLoggerFacade>();
            var result2 = container.Resolve <ISimpleLoggerFacade>();

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <SimpleLoggerFacade>(result1);
            Assert.IsInstanceOf <SimpleLoggerFacade>(result2);
            Assert.AreEqual(result1, result2);
        }
 private IMapper Create()
 {
     var bootstrapper = new WindsorBootstrapper(WindsorLifestyles.Transient);
     return bootstrapper.Bootstrap().Resolve<IMapper>();
 }
Beispiel #6
0
 public EasyBlockService() : this(WindsorBootstrapper.Bootstrap())
 {
 }
Beispiel #7
0
 private IWindsorContainer Create()
 {
     return(WindsorBootstrapper.Bootstrap());
 }