public void GetSubscribers() { var timeoutCommands = SubscriptionCommandBuilder.Build(sqlDialect, "TheTablePrefix"); // TODO: Not much point validating a type name Approver.Verify(timeoutCommands.GetSubscribers.ToString(), scenario: GetType().Name); }
public void Write() { var directory = Path.Combine(TestContext.CurrentContext.TestDirectory, "../../"); foreach (var variant in Enum.GetValues(typeof(BuildSqlVariant)).Cast <BuildSqlVariant>()) { Write(directory, variant, "TimeoutCreate", TimeoutScriptBuilder.BuildCreateScript(variant)); Write(directory, variant, "TimeoutDrop", TimeoutScriptBuilder.BuildDropScript(variant)); Write(directory, variant, "OutboxCreate", OutboxScriptBuilder.BuildCreateScript(variant)); Write(directory, variant, "OutboxDrop", OutboxScriptBuilder.BuildDropScript(variant)); Write(directory, variant, "SubscriptionCreate", SubscriptionScriptBuilder.BuildCreateScript(variant)); Write(directory, variant, "SubscriptionDrop", SubscriptionScriptBuilder.BuildDropScript(variant)); var sagaDefinition = new SagaDefinition( tableSuffix: "OrderSaga", name: "OrderSaga", correlationProperty: new CorrelationProperty( name: "OrderNumber", type: CorrelationPropertyType.Int), transitionalCorrelationProperty: new CorrelationProperty( name: "OrderId", type: CorrelationPropertyType.Guid)); Write(directory, variant, "SagaCreate", SagaScriptBuilder.BuildCreateScript(sagaDefinition, variant)); Write(directory, variant, "SagaDrop", SagaScriptBuilder.BuildDropScript(sagaDefinition, variant)); } foreach (var variant in Enum.GetValues(typeof(SqlVariant)).Cast <SqlVariant>()) { var timeoutCommands = TimeoutCommandBuilder.Build(sqlVariant: variant, tablePrefix: "EndpointName"); Write(directory, variant, "TimeoutAdd", timeoutCommands.Add); Write(directory, variant, "TimeoutNext", timeoutCommands.Next); Write(directory, variant, "TimeoutRange", timeoutCommands.Range); Write(directory, variant, "TimeoutRemoveById", timeoutCommands.RemoveById); Write(directory, variant, "TimeoutRemoveBySagaId", timeoutCommands.RemoveBySagaId); Write(directory, variant, "TimeoutPeek", timeoutCommands.Peek); var outboxCommands = OutboxCommandBuilder.Build(variant, "EndpointName"); Write(directory, variant, "OutboxCleanup", outboxCommands.Cleanup); Write(directory, variant, "OutboxGet", outboxCommands.Get); Write(directory, variant, "OutboxSetAsDispatched", outboxCommands.SetAsDispatched); Write(directory, variant, "OutboxStore", outboxCommands.Store); var subscriptionCommands = SubscriptionCommandBuilder.Build(variant, "EndpointName"); Write(directory, variant, "SubscriptionSubscribe", subscriptionCommands.Subscribe); Write(directory, variant, "SubscriptionUnsubscribe", subscriptionCommands.Unsubscribe); Write(directory, variant, "SubscriptionGetSubscribers", subscriptionCommands.GetSubscribers(new List <MessageType> { new MessageType("MessageTypeName", new Version()) })); var sagaCommandBuilder = new SagaCommandBuilder(variant, "EndpointName"); Write(directory, variant, "SagaComplete", sagaCommandBuilder.BuildCompleteCommand("SagaName")); Write(directory, variant, "SagadGetByProperty", sagaCommandBuilder.BuildGetByPropertyCommand("SagaName", "PropertyName")); Write(directory, variant, "SagaGetBySagaId", sagaCommandBuilder.BuildGetBySagaIdCommand("SagaName")); Write(directory, variant, "SagaSave", sagaCommandBuilder.BuildSaveCommand("SagaName", "CorrelationPproperty", "TransitionalCorrelationPproperty")); Write(directory, variant, "SagaUpdate", sagaCommandBuilder.BuildUpdateCommand("SagaName", "TransitionalCorrelationPproperty")); } }
public void Unsubscribe() { var timeoutCommands = SubscriptionCommandBuilder.Build(sqlDialect, "TheTablePrefix"); using (NamerFactory.AsEnvironmentSpecificTest(() => GetType().Name)) { Approvals.Verify(timeoutCommands.Unsubscribe); } }
public SubscriptionPersister(Func <DbConnection> connectionBuilder, string tablePrefix, SqlDialect sqlDialect, TimeSpan?cacheFor) { this.connectionBuilder = connectionBuilder; this.sqlDialect = sqlDialect; this.cacheFor = cacheFor; subscriptionCommands = SubscriptionCommandBuilder.Build(sqlDialect, tablePrefix); if (cacheFor != null) { Cache = new ConcurrentDictionary <string, CacheItem>(); } }
public void Write() { var directory = Path.Combine(TestContext.CurrentContext.TestDirectory, "../../../"); foreach (var variant in Enum.GetValues(typeof(BuildSqlDialect)).Cast <BuildSqlDialect>()) { Write(directory, variant, "TimeoutCreate", TimeoutScriptBuilder.BuildCreateScript(variant)); Write(directory, variant, "TimeoutDrop", TimeoutScriptBuilder.BuildDropScript(variant)); Write(directory, variant, "OutboxCreate", OutboxScriptBuilder.BuildCreateScript(variant)); Write(directory, variant, "OutboxDrop", OutboxScriptBuilder.BuildDropScript(variant)); Write(directory, variant, "SubscriptionCreate", SubscriptionScriptBuilder.BuildCreateScript(variant)); Write(directory, variant, "SubscriptionDrop", SubscriptionScriptBuilder.BuildDropScript(variant)); var sagaDefinition = new SagaDefinition( tableSuffix: "OrderSaga", name: "OrderSaga", correlationProperty: new CorrelationProperty( name: "OrderNumber", type: CorrelationPropertyType.Int), transitionalCorrelationProperty: new CorrelationProperty( name: "OrderId", type: CorrelationPropertyType.Guid)); Write(directory, variant, "SagaCreate", SagaScriptBuilder.BuildCreateScript(sagaDefinition, variant)); Write(directory, variant, "SagaDrop", SagaScriptBuilder.BuildDropScript(sagaDefinition, variant)); } var dialects = new SqlDialect[] { new SqlDialect.MsSqlServer(), new SqlDialect.MySql(), new SqlDialect.Oracle(), new SqlDialect.PostgreSql() }; foreach (var dialect in dialects) { var timeoutCommands = TimeoutCommandBuilder.Build( sqlDialect: dialect, tablePrefix: "EndpointName"); Write(directory, dialect, "TimeoutAdd", timeoutCommands.Add); Write(directory, dialect, "TimeoutNext", timeoutCommands.Next); Write(directory, dialect, "TimeoutRange", timeoutCommands.Range); Write(directory, dialect, "TimeoutRemoveById", timeoutCommands.RemoveById); Write(directory, dialect, "TimeoutRemoveBySagaId", timeoutCommands.RemoveBySagaId); Write(directory, dialect, "TimeoutPeek", timeoutCommands.Peek); var outboxCommands = OutboxCommandBuilder.Build( tablePrefix: "EndpointName", sqlDialect: dialect); Write(directory, dialect, "OutboxCleanup", outboxCommands.Cleanup); Write(directory, dialect, "OutboxGet", outboxCommands.Get); Write(directory, dialect, "OutboxSetAsDispatched", outboxCommands.SetAsDispatched); Write(directory, dialect, "OutboxStore", outboxCommands.Store); var subscriptionCommands = SubscriptionCommandBuilder.Build( sqlDialect: dialect, tablePrefix: "EndpointName"); Write(directory, dialect, "SubscriptionSubscribe", subscriptionCommands.Subscribe); Write(directory, dialect, "SubscriptionUnsubscribe", subscriptionCommands.Unsubscribe); Write(directory, dialect, "SubscriptionGetSubscribers", subscriptionCommands.GetSubscribers(new List <MessageType> { new MessageType("MessageTypeName", new Version()) })); Write(directory, dialect, "SagaComplete", dialect.BuildCompleteCommand("EndpointName_SagaName")); Write(directory, dialect, "SagaGetByProperty", dialect.BuildGetByPropertyCommand("PropertyName", "EndpointName_SagaName")); Write(directory, dialect, "SagaGetBySagaId", dialect.BuildGetBySagaIdCommand("EndpointName_SagaName")); Write(directory, dialect, "SagaSave", dialect.BuildSaveCommand("CorrelationProperty", "TransitionalCorrelationProperty", "EndpointName_SagaName")); Write(directory, dialect, "SagaUpdate", dialect.BuildUpdateCommand("TransitionalCorrelationProperty", "EndpointName_SagaName")); // since we don't have doco on oracle saga finders if (!(dialect is SqlDialect.Oracle)) { var createSelectWithWhereClause = dialect.BuildSelectFromCommand("EndpointName_SagaName"); Write(directory, dialect, "SagaSelect", createSelectWithWhereClause("1 = 1")); } } }
public void Unsubscribe() { var timeoutCommands = SubscriptionCommandBuilder.Build(sqlDialect, "TheTablePrefix"); Approver.Verify(timeoutCommands.Unsubscribe, scenario: GetType().Name); }