public void ActiveRecordUnitOfWorkFacilityWillRegisterIRepositoryAndUnitOfWorkFactory() { RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities.boo"); Assert.IsTrue(container.Kernel.HasComponent(typeof(IRepository <>))); Assert.IsTrue(container.Kernel.HasComponent(typeof(IUnitOfWorkFactory))); }
public void CanGetInterfaceByPredicate() { RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo"); IHandler handler = container.Kernel.GetHandler("foo54"); Assert.IsNotNull(handler); Assert.AreEqual(typeof(IFoo54), handler.ComponentModel.Service); Assert.AreEqual(typeof(Fubar54), handler.ComponentModel.Implementation); }
public void CanGetAllTypesByPredicate() { RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo"); IHandler handler = container.Kernel.GetHandler("nh.repos"); Assert.IsNotNull(handler); Assert.AreEqual(typeof(IRepository<>), handler.ComponentModel.Service.GetGenericTypeDefinition()); Assert.AreEqual(typeof(NHRepository<>), handler.ComponentModel.Implementation); }
public void CanCreateActiveRecordUnitOfWorkFacility() { RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities.boo"); IFacility[] facilities = container.Kernel.GetFacilities(); ActiveRecordUnitOfWorkFacility activeRecordUnitOfWorkFactory = (ActiveRecordUnitOfWorkFacility)facilities[0]; Assert.AreEqual(System.Reflection.Assembly.Load("Rhino.Commons.Binsor"), activeRecordUnitOfWorkFactory.Assemblies[0]); }
public void ContainerUsesXmlConfigurationIfNotBooExtension() { RhinoContainer container = new RhinoContainer(@"Binsor\Windsor.xml"); ISender sender = container.Resolve <ISender>(); Assert.IsNotNull(sender); }
public void CanGetAllTypesByPredicate() { RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo"); IHandler handler = container.Kernel.GetHandler("nh.repos"); Assert.IsNotNull(handler); Assert.AreEqual(typeof(IRepository <>), handler.ComponentModel.Service.GetGenericTypeDefinition()); Assert.AreEqual(typeof(NHRepository <>), handler.ComponentModel.Implementation); }
public void CanExtendComponentsRegisteredInFacilities() { using (IWindsorContainer container = new RhinoContainer()) { string path = Path.GetFullPath(@"Binsor\PreRegistrationWithExtensions.boo"); BooReader.Read(container, path); ShippingCalculator calculator = container.Resolve <ShippingCalculator>(); Assert.AreEqual(120m, calculator.ShippingCost); } }
public void CanExtendComponentsRegisteredInFacilities() { using (IWindsorContainer container = new RhinoContainer()) { string path = Path.GetFullPath(@"Binsor\PreRegistrationWithExtensions.boo"); BooReader.Read(container, path); ShippingCalculator calculator = container.Resolve<ShippingCalculator>(); Assert.AreEqual(120m, calculator.ShippingCost); } }
public void CanUseEnvironmentInfoPassedInToContainer() { Assert.IsFalse(_container.Kernel.HasComponent("foo_bar")); string path = Path.GetFullPath(@"Binsor\Windsor2.boo"); RhinoContainer container = new RhinoContainer(path, new TestEnvironmentInfo("Binsor2")); Fubar fubar = container.Resolve <Fubar>("foo_bar"); Assert.IsNotNull(fubar); Assert.AreEqual("Binsor2", fubar.Foo); }
public void CanExtendComponentsRegisteredInCode() { using (IWindsorContainer container = new RhinoContainer()) { container.Register(Component.For <GstCalculator>() .Named("gstcalculator") .DependsOn(Property.ForKey("GstRate").Eq(15m))); IWindsorInstaller installer = BinsorScript.Inline(new StringBuilder().AppendLine("extend \"gstcalculator\":") .AppendLine(" GstRate = decimal(50)").ToString()); installer.Install(container, null); GstCalculator calculator = container.Resolve <GstCalculator>(); Assert.AreEqual(50m, calculator.GstRate); } }
public void CanExtendComponentsRegisteredInCode() { using (IWindsorContainer container = new RhinoContainer()) { container.Register(Component.For<GstCalculator>() .Named("gstcalculator") .DependsOn(Property.ForKey("GstRate").Eq(15m))); IWindsorInstaller installer = BinsorScript.Inline(new StringBuilder().AppendLine("extend \"gstcalculator\":") .AppendLine(" GstRate = decimal(50)").ToString()); installer.Install(container, null); GstCalculator calculator = container.Resolve<GstCalculator>(); Assert.AreEqual(50m, calculator.GstRate); } }
static void Main(string[] args) { try { RhinoContainer container = new RhinoContainer("Windsor.boo"); IoC.Initialize(container); ContainerSelector containerSelector = IoC.Resolve<ContainerSelector>(); containerSelector.PrintChildContainers(); using(UnitOfWork.Start()) { Console.WriteLine( NHibernateUnitOfWorkFactory.CurrentNHibernateSession .Connection.ConnectionString ); } using(containerSelector.Enter("Northwind")) { using (UnitOfWork.Start()) { Console.WriteLine( NHibernateUnitOfWorkFactory.CurrentNHibernateSession .Connection.ConnectionString ); } } using (containerSelector.Enter("Southsand")) { using (UnitOfWork.Start()) { Console.WriteLine( NHibernateUnitOfWorkFactory.CurrentNHibernateSession .Connection.ConnectionString ); } } } catch (Exception e) { System.Console.WriteLine(e); } }
static void Main(string[] args) { try { RhinoContainer container = new RhinoContainer("Windsor.boo"); IoC.Initialize(container); ContainerSelector containerSelector = IoC.Resolve <ContainerSelector>(); containerSelector.PrintChildContainers(); using (UnitOfWork.Start()) { Console.WriteLine( NHibernateUnitOfWorkFactory.CurrentNHibernateSession .Connection.ConnectionString ); } using (containerSelector.Enter("Northwind")) { using (UnitOfWork.Start()) { Console.WriteLine( NHibernateUnitOfWorkFactory.CurrentNHibernateSession .Connection.ConnectionString ); } } using (containerSelector.Enter("Southsand")) { using (UnitOfWork.Start()) { Console.WriteLine( NHibernateUnitOfWorkFactory.CurrentNHibernateSession .Connection.ConnectionString ); } } } catch (Exception e) { System.Console.WriteLine(e); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); RhinoContainer container = new RhinoContainer(".\\config\\Windsor.config"); IoC.Initialize(container); container.Kernel.AddFacility("nh", new NHibernateUnitOfWorkFacility()); EnableNhibernateLogging(); CreateDB(container); FirstUseOfRepository(); //_ieForm = new IeTestingForm(); ////if no password & login then show config form //MbankSettings settings = Properties.Settings.Default.MyMbankSettings; //if (settings == null) //{ // _ieForm.Visible = false; // Form configForm = new ConfigureMbank(); // configForm.Closed += new EventHandler(f_Closing); // configForm.Show(); //} //else //{ // _ieForm.Go(Properties.Settings.Default.MyMbankSettings); //} //form = new GroupsForm(); //form.Show(); CreditFormMVP form = new CreditFormMVP(); CreditPresenter creditPresenter = new CreditPresenter(new Credit(), form); //form.Show(); //Application.Run(_ieForm); Application.Run(form); }
private static void PrepareDatabase(bool createDB) { try { Configuration cfg = new Configuration().Configure(@"hibernate.cfg.xml"); //must be in root dir ISessionFactory factory = cfg.BuildSessionFactory(); if (createDB) { new SchemaExport(cfg).Create(true, true); // creates structure at database } RhinoContainer container = new RhinoContainer(".\\config\\Windsor.config"); IoC.Initialize(container); IoC.Container.Kernel.AddComponentInstance("nhibernate_cfg", cfg); IoC.Resolve<IUnitOfWorkFactory>().Init(); } catch (Exception e) { Console.WriteLine(e); throw e; } }
public void ContainerUsesXmlConfigurationIfNotBooExtension() { RhinoContainer container = new RhinoContainer(@"Binsor\Windsor.xml"); ISender sender = container.Resolve<ISender>(); Assert.IsNotNull(sender); }
public void CanGetAllTypesByNamespace() { RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo"); Assert.IsNotNull(container[typeof(UsingAllTypesFixture)]); }
public void ActiveRecordUnitOfWorkFacilityWillRegisterIRepositoryWithRepositoryKey() { RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities2.boo"); Assert.IsTrue(container.Kernel.HasComponent("default_repository")); }
public void CanUseEnvironmentInfoPassedInToContainer() { Assert.IsFalse(_container.Kernel.HasComponent("foo_bar")); string path = Path.GetFullPath(@"Binsor\Windsor2.boo"); RhinoContainer container = new RhinoContainer(path, new TestEnvironmentInfo("Binsor2")); Fubar fubar = container.Resolve<Fubar>("foo_bar"); Assert.IsNotNull(fubar); Assert.AreEqual("Binsor2", fubar.Foo); }
public void CanGetAllTypesByBaseType() { RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo"); Assert.IsNotNull(container[typeof(MyView)]); }
public void CanGetAllTypesByAttribute() { RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo"); Assert.IsNotNull(container[typeof(Controller)]); }
public void ActiveRecordUnitOfWorkFacilityWillRegisterIRepositoryAndUnitOfWorkFactory() { RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities.boo"); Assert.IsTrue(container.Kernel.HasComponent(typeof (IRepository<>))); Assert.IsTrue(container.Kernel.HasComponent(typeof(IUnitOfWorkFactory))); }