public void RequireFinderForMessagesStartingTheSaga() { var ex = Assert.Throws <Exception>(() => TypeBasedSagaMetaModel.Create(typeof(MySagaWithUnmappedStartProperty))); Assert.True(ex.Message.Contains(typeof(MessageThatStartsTheSaga).FullName)); }
public void HandleNonExistingFinders() { var metadata = TypeBasedSagaMetaModel.Create(typeof(MySagaWithUnmappedStartProperty)); SagaFinderDefinition finder; Assert.False(metadata.TryGetFinder(typeof(MessageThatStartsTheSaga).FullName, out finder)); }
public void HandleBothUniqueAttributeAndMapping() { var metadata = TypeBasedSagaMetaModel.Create(typeof(MySagaWithMappedAndUniqueProperty)); Assert.AreEqual("UniqueProperty", metadata.CorrelationProperties.Single().Name); }
public void AutomaticallyAddUniqueForMappedProperties() { var metadata = TypeBasedSagaMetaModel.Create(typeof(MySagaWithMappedProperty)); Assert.AreEqual("UniqueProperty", metadata.CorrelationProperties.Single().Name); }
public void GetEntityClrType() { var metadata = TypeBasedSagaMetaModel.Create(typeof(MySaga)); Assert.AreEqual(typeof(MyEntity), metadata.SagaEntityType); }
public void DetectUniquePropertiesByAttribute() { var metadata = TypeBasedSagaMetaModel.Create(typeof(MySaga)); Assert.AreEqual("UniqueProperty", metadata.CorrelationProperties.Single().Name); }
public void ValidateThatMappingOnSagaIdHasTypeGuidForMessageFields() { var ex = Assert.Throws <Exception>(() => TypeBasedSagaMetaModel.Create(typeof(SagaWithIdMappedToNonGuidMessageField))); Assert.True(ex.Message.Contains(typeof(SomeMessage).Name)); }
public void DetectAndRegisterPropertyFinders() { var metadata = TypeBasedSagaMetaModel.Create(typeof(MySagaWithMappedProperty)); var finder = GetFinder(metadata, typeof(SomeMessage).FullName); Assert.AreEqual(typeof(PropertySagaFinder <MySagaWithMappedProperty.SagaData>), finder.Type); Assert.NotNull(finder.Properties["property-accessor"]); Assert.AreEqual("UniqueProperty", finder.Properties["saga-property-name"]); }
public void DetectAndRegisterCustomFindersUsingScanning() { var metadata = TypeBasedSagaMetaModel.Create(typeof(MySagaWithScannedFinder), new List <Type> { typeof(MySagaWithScannedFinder.CustomFinder) }, new Conventions()); var finder = GetFinder(metadata, typeof(SomeMessage).FullName); Assert.AreEqual(typeof(CustomFinderAdapter <MySagaWithScannedFinder.SagaData, SomeMessage>), finder.Type); Assert.AreEqual(typeof(MySagaWithScannedFinder.CustomFinder), finder.Properties["custom-finder-clr-type"]); }
public void DetectMessagesStartingTheSaga() { var metadata = TypeBasedSagaMetaModel.Create(typeof(SagaWith2StartersAnd1Handler)); var messages = metadata.AssociatedMessages; Assert.AreEqual(4, messages.Count()); Assert.True(metadata.IsMessageAllowedToStartTheSaga(typeof(SagaWith2StartersAnd1Handler.StartMessage1).FullName)); Assert.True(metadata.IsMessageAllowedToStartTheSaga(typeof(SagaWith2StartersAnd1Handler.StartMessage2).FullName)); Assert.False(metadata.IsMessageAllowedToStartTheSaga(typeof(SagaWith2StartersAnd1Handler.Message3).FullName)); Assert.False(metadata.IsMessageAllowedToStartTheSaga(typeof(SagaWith2StartersAnd1Handler.MyTimeout).FullName)); }
/// <summary> /// See <see cref="Feature.Setup" /> /// </summary> protected internal override void Setup(FeatureConfigurationContext context) { // Register the Saga related behavior for incoming messages context.Pipeline.Register <SagaPersistenceBehavior.Registration>(); var typeBasedSagas = TypeBasedSagaMetaModel.Create(context.Settings.GetAvailableTypes(), conventions); var sagaMetaModel = new SagaMetaModel(typeBasedSagas); RegisterCustomFindersInContainer(context.Container, sagaMetaModel); context.Container.RegisterSingleton(sagaMetaModel); foreach (var t in context.Settings.GetAvailableTypes()) { if (IsSagaNotFoundHandler(t)) { context.Container.ConfigureComponent(t, DependencyLifecycle.InstancePerCall); } } }
public void SetUp() { persister = new InMemorySagaPersister(new SagaMetaModel(TypeBasedSagaMetaModel.Create(sagaTypes, new Conventions()))); }
public void GetEntityClrTypeFromInheritanceChain() { var metadata = TypeBasedSagaMetaModel.Create(typeof(SagaWithInheritanceChain)); Assert.AreEqual(typeof(SagaWithInheritanceChain.SagaData), metadata.SagaEntityType); }
public void Throws_when_does_not_implement_generic_saga() { Assert.Throws <Exception>(() => TypeBasedSagaMetaModel.Create(typeof(MyNonGenericSaga))); }
SagaMetaModel GetModel(params Type[] types) { return(new SagaMetaModel(TypeBasedSagaMetaModel.Create(types.ToList(), new Conventions()))); }