public void HasIsTransactionalButNothingIsConfigured() { WindsorContainer container = new WindsorContainer("HasIsTransactionalButNothingIsConfigured.xml"); TransactionMetaInfoStore metaInfoStore = container.Resolve <TransactionMetaInfoStore>(); TransactionMetaInfo meta = metaInfoStore.GetMetaFor(typeof(TransactionalComp1)); Assert.IsNull(meta); }
public void ConfigForServiceWithInterface() { WindsorContainer container = new WindsorContainer("ConfigForServiceWithInterface.xml"); TransactionMetaInfoStore metaInfoStore = container.Resolve <TransactionMetaInfoStore>(); TransactionMetaInfo meta = metaInfoStore.GetMetaFor(typeof(TransactionalComp3)); Assert.IsNotNull(meta); Assert.AreEqual(2, meta.Methods.Count()); }
public void ValidConfigForInheritedMethods() { WindsorContainer container = new WindsorContainer("ValidConfigForInheritedMethods.xml"); TransactionMetaInfoStore metaInfoStore = container.Resolve <TransactionMetaInfoStore>(); TransactionMetaInfo meta = metaInfoStore.GetMetaFor(typeof(TransactionalComp2)); Assert.IsNotNull(meta); Assert.AreEqual(4, meta.Methods.Count()); }
public void HasConfiguration() { WindsorContainer container = new WindsorContainer("HasConfiguration.xml"); TransactionMetaInfoStore metaInfoStore = container.Resolve <TransactionMetaInfoStore>(); TransactionMetaInfo meta = metaInfoStore.GetMetaFor(typeof(TransactionalComp1)); Assert.IsNotNull(meta); Assert.AreEqual(3, meta.Methods.Count()); }
private static void AddTransactionInterceptorIfIsTransactional(ComponentModel model, TransactionMetaInfoStore store) { TransactionMetaInfo meta = store.GetMetaFor(model.Implementation); if (meta == null) { return; } model.Dependencies.Add(new DependencyModel(null, typeof(TransactionInterceptor), false)); model.Interceptors.AddFirst(new InterceptorReference("eventsourcing.transaction.interceptor")); }
private void Validate(ComponentModel model, TransactionMetaInfoStore store) { if (model.Services.Count() == 0 || model.Services.All(o => o.IsInterface)) { return; } TransactionMetaInfo meta = store.GetMetaFor(model.Implementation); if (meta == null) { return; } ArrayList problematicMethods = new ArrayList(); foreach (MethodInfo method in meta.Methods) { if (!method.IsVirtual) { problematicMethods.Add(method.Name); } } if (problematicMethods.Count != 0) { string[] methodNames = (string[])problematicMethods.ToArray(typeof(string)); string message = string.Format("The class {0} wants to use transaction interception, " + "however the methods must be marked as virtual in order to do so. Please correct " + "the following methods: {1}", model.Implementation.FullName, string.Join(", ", methodNames)); throw new FacilityException(message); } }