public async Task TestStoringSagas(ConventionType seedType)
        {
            using (var db = new ReusableDB())
            {
                List<TestSagaData> sagas;

                using (var store = db.NewStore())
                {
                    ApplyPrefillConventions(store, seedType);
                    store.Initialize();

                    sagas = await Prefill(store, seedType);
                }

                using (var store = db.NewStore())
                {
                    Console.WriteLine($"Testing saga updates with DocumentStore initially configured for {seedType} conventions.");
                    ApplyTestConventions(store, seedType);
                    store.Initialize();

                    // Update each saga, once by id and once by correlation property
                    foreach (var saga in sagas)
                    {
                        var persister = new SagaPersister();
                        Console.WriteLine($"Retrieving SagaId {saga.Id} by SagaId");
                        using (var session = store.OpenAsyncSession())
                        {
                            var ravenDBSynchronizedStorageSession = new RavenDBSynchronizedStorageSession(session, false);
                            var byId = await persister.Get<TestSagaData>(saga.Id, ravenDBSynchronizedStorageSession, null);
                            Assert.IsNotNull(byId);

                            byId.Counter++;
                            await persister.Update(byId, ravenDBSynchronizedStorageSession, null);
                            await session.SaveChangesAsync();

                            Console.WriteLine($"Retrieving SagaId {saga.Id} by Correlation Property OrderId={saga.OrderId}");
                            var byOrderId = await persister.Get<TestSagaData>("OrderId", saga.OrderId, ravenDBSynchronizedStorageSession, new ContextBag());
                            Assert.IsNotNull(byOrderId);

                            byOrderId.Counter++;
                            await persister.Update(byOrderId, ravenDBSynchronizedStorageSession, null);
                            await session.SaveChangesAsync();
                        }
                    }

                    Console.WriteLine("Retrieving each saga again by SagaId and making sure Counter == 3");
                    foreach (var saga in sagas)
                    {
                        var persister = new SagaPersister();
                        using (var session = store.OpenAsyncSession())
                        {
                            Console.WriteLine($"Retrieving SagaId {saga.Id} by SagaId");
                            var byId = await persister.Get<TestSagaData>(saga.Id, new RavenDBSynchronizedStorageSession(session, false), null);
                            Assert.IsNotNull(byId);
                            Assert.AreEqual(3, byId.Counter);
                        }
                    }
                }
            }
        }
Пример #2
0
        private bool Conv(ConventionType convention, string input, out string output)
        {
            var tokens = CaseTokenizer.Tokenize(input);

            switch (convention)
            {
                case ConventionType.HttpHeader:
                    output = CaseConv.Join(tokens, CaseType.HttpHeader);
                    return true;
                case ConventionType.Pascal:
                    output = CaseConv.Join(tokens, CaseType.Pascal);
                    return true;
                case ConventionType.Snake:
                    output = CaseConv.Join(tokens, CaseType.Snake);
                    return true;
                case ConventionType.Camel:
                    output = CaseConv.Join(tokens, CaseType.Camel);
                    return true;

                case ConventionType.Dontcare:
                    output = input;
                    return true;
            }

            output = input;
            return false;
        }
        private bool Conv(ConventionType convention, string input, out string output)
        {
            var tokens = CaseTokenizer.Tokenize(input);

            switch (convention)
            {
            case ConventionType.HttpHeader:
                output = CaseConv.Join(tokens, CaseType.HttpHeader);
                return(true);

            case ConventionType.Pascal:
                output = CaseConv.Join(tokens, CaseType.Pascal);
                return(true);

            case ConventionType.Snake:
                output = CaseConv.Join(tokens, CaseType.Snake);
                return(true);

            case ConventionType.Camel:
                output = CaseConv.Join(tokens, CaseType.Camel);
                return(true);

            case ConventionType.Dontcare:
                output = input;
                return(true);
            }

            output = input;
            return(false);
        }
        public async Task TestMarkingAsComplete(ConventionType seedType)
        {
            using (var db = new ReusableDB())
            {
                List <TestSagaData> sagas;

                using (var store = db.NewStore())
                {
                    ApplyPrefillConventions(store, seedType);
                    store.Initialize();

                    sagas = await Prefill(store, seedType);
                }

                using (var store = db.NewStore())
                {
                    Console.WriteLine($"Testing saga lookups with DocumentStore initially configured for {seedType} conventions.");
                    ApplyTestConventions(store, seedType);
                    store.Initialize();

                    // Update each saga, once by id and once by correlation property
                    foreach (var saga in sagas)
                    {
                        var persister = new SagaPersister();
                        using (var session = store.OpenAsyncSession())
                        {
                            Console.WriteLine($"Retrieving SagaId {saga.Id} by Correlation Property OrderId={saga.OrderId} and completing.");
                            var ravenDBSynchronizedStorageSession = new RavenDBSynchronizedStorageSession(session, false);
                            var contextBag = new ContextBag();
                            var byOrderId  = await persister.Get <TestSagaData>("OrderId", saga.OrderId, ravenDBSynchronizedStorageSession, contextBag);

                            Assert.IsNotNull(byOrderId);

                            await persister.Complete(byOrderId, ravenDBSynchronizedStorageSession, contextBag);

                            await session.SaveChangesAsync();
                        }
                    }

                    db.WaitForIndexing(store);

                    // Ensure terms are still the saga type and unique identity type
                    var terms = store.DatabaseCommands.GetTerms("Raven/DocumentsByEntityName", "Tag", null, 1024).ToList();
                    Assert.AreEqual(2, terms.Count);

                    foreach (var term in terms)
                    {
                        var query = new IndexQuery
                        {
                            Query    = "Tag:" + term,
                            PageSize = 0
                        };

                        // Ensure there are none left
                        var queryResult = store.DatabaseCommands.Query("Raven/DocumentsByEntityName", query);
                        Assert.AreEqual(0, queryResult.TotalResults);
                    }
                }
            }
        }
        public async Task TestRetrievingSagas(ConventionType seedType)
        {
            using (var db = new ReusableDB())
            {
                List<TestSagaData> sagas;

                using (var store = db.NewStore())
                {
                    ApplyPrefillConventions(store, seedType);
                    store.Initialize();

                    sagas = await Prefill(store, seedType);
                }

                // Need to ensure multiple runs will work, after conventions document is stored
                for (var i = 0; i < 3; i++)
                {
                    using (var store = db.NewStore())
                    {
                        Console.WriteLine($"Testing saga lookups with DocumentStore initially configured for {seedType} conventions.");
                        ApplyTestConventions(store, seedType);
                        store.Initialize();

                        foreach (var saga in sagas)
                        {
                            var persister = new SagaPersister();
                            Console.WriteLine($"Retrieving SagaId {saga.Id} by SagaId");
                            TestSagaData byId;
                            using (var session = store.OpenAsyncSession())
                            {
                                byId = await persister.Get<TestSagaData>(saga.Id, new RavenDBSynchronizedStorageSession(session, false), null);
                            }
                            Assert.IsNotNull(byId);
                            Assert.AreEqual(byId.Id, saga.Id);
                            Assert.AreEqual(byId.OrderId, saga.OrderId);
                            Assert.AreEqual(byId.OriginalMessageId, saga.OriginalMessageId);
                            Assert.AreEqual(byId.Originator, saga.Originator);
                            Assert.AreEqual(1, saga.Counter);

                            Console.WriteLine($"Retrieving SagaId {saga.Id} by Correlation Property OrderId={saga.OrderId}");
                            using (var session = store.OpenAsyncSession())
                            {
                                byId = await persister.Get<TestSagaData>("OrderId", saga.OrderId, new RavenDBSynchronizedStorageSession(session, false), new ContextBag());
                            }
                            Assert.IsNotNull(byId);
                            Assert.AreEqual(byId.Id, saga.Id);
                            Assert.AreEqual(byId.OrderId, saga.OrderId);
                            Assert.AreEqual(byId.OriginalMessageId, saga.OriginalMessageId);
                            Assert.AreEqual(byId.Originator, saga.Originator);
                            Assert.AreEqual(1, saga.Counter);
                        }
                    }
                }
            }
        }
        public async Task TestRetrievingSagas(ConventionType seedType)
        {
            using (var db = new ReusableDB())
            {
                List <TestSagaData> sagas;

                using (var store = db.NewStore())
                {
                    ApplyPrefillConventions(store, seedType);
                    store.Initialize();

                    sagas = await Prefill(store, seedType);
                }

                // Need to ensure multiple runs will work, after conventions document is stored
                for (var i = 0; i < 3; i++)
                {
                    using (var store = db.NewStore())
                    {
                        Console.WriteLine($"Testing saga lookups with DocumentStore initially configured for {seedType} conventions.");
                        ApplyTestConventions(store, seedType);
                        store.Initialize();

                        foreach (var saga in sagas)
                        {
                            var persister = new SagaPersister();
                            Console.WriteLine($"Retrieving SagaId {saga.Id} by SagaId");
                            TestSagaData byId;
                            using (var session = store.OpenAsyncSession())
                            {
                                byId = await persister.Get <TestSagaData>(saga.Id, new RavenDBSynchronizedStorageSession(session, false), null);
                            }
                            Assert.IsNotNull(byId);
                            Assert.AreEqual(byId.Id, saga.Id);
                            Assert.AreEqual(byId.OrderId, saga.OrderId);
                            Assert.AreEqual(byId.OriginalMessageId, saga.OriginalMessageId);
                            Assert.AreEqual(byId.Originator, saga.Originator);
                            Assert.AreEqual(1, saga.Counter);

                            Console.WriteLine($"Retrieving SagaId {saga.Id} by Correlation Property OrderId={saga.OrderId}");
                            using (var session = store.OpenAsyncSession())
                            {
                                byId = await persister.Get <TestSagaData>("OrderId", saga.OrderId, new RavenDBSynchronizedStorageSession(session, false), new ContextBag());
                            }
                            Assert.IsNotNull(byId);
                            Assert.AreEqual(byId.Id, saga.Id);
                            Assert.AreEqual(byId.OrderId, saga.OrderId);
                            Assert.AreEqual(byId.OriginalMessageId, saga.OriginalMessageId);
                            Assert.AreEqual(byId.Originator, saga.Originator);
                            Assert.AreEqual(1, saga.Counter);
                        }
                    }
                }
            }
        }
Пример #7
0
 public string GetNamingConvention(string name, ConventionType conventionType)
 {
     if (conventionType == ConventionType.Type)
     {
         return(name);
     }
     else if (conventionType == ConventionType.Field)
     {
     }
     return(string.Empty);
 }
        private async Task <List <TestSagaData> > Prefill(IDocumentStore store, ConventionType seedType)
        {
            var snooper = StoreSnooper.Install(store);

            Console.WriteLine($"Filling database with saga data, using {seedType} conventions");

            var names = new Dictionary <ConventionType, string>
            {
                { ConventionType.RavenDefault, "TestSagaDatas" },
                { ConventionType.NSBDefault, "TestSaga" },
                { ConventionType.Customer, "ataDagaStseT" }
            };
            var name = names[seedType];

            var sagas = Enumerable.Range(1001, 10)
                        .Select(orderId => new TestSagaData
            {
                Id                = Guid.NewGuid(),
                OrderId           = orderId,
                OriginalMessageId = Guid.NewGuid().ToString(),
                Originator        = "SomeSaga",
                Counter           = 1
            })
                        .ToList();


            foreach (var saga in sagas)
            {
                snooper.Clear();

                var persister = new SagaPersister();

                Console.WriteLine($"Storing SagaId {saga.Id}");
                using (var session = store.OpenAsyncSession())
                {
                    await persister.Save(saga, new SagaCorrelationProperty("OrderId", saga.OrderId), new RavenDBSynchronizedStorageSession(session, false), null);

                    await session.SaveChangesAsync();
                }
                var keysStored = snooper.KeysStored.ToList();

                foreach (var key in keysStored)
                {
                    Console.WriteLine($"  * Document created: {key}");
                }

                Assert.AreEqual(2, snooper.KeyCount);
                Assert.Contains($"{name}/{saga.Id}", keysStored);
            }

            return(sagas);
        }
Пример #9
0
        /// <summary>
        /// Sets the formatting convention style.
        /// </summary>
        /// <param name="text">The text to apply the formatting to.</param>
        /// <param name="format">The type of the formatting to apply.</param>
        /// <returns>The formatted string.</returns>
        public static string Convention(this string text, ConventionType format)
        {
            switch (format)
            {
            case ConventionType.PascalCase: return(text.PascalCase());

            case ConventionType.CamelCase: return(text.CamelCase());

            case ConventionType.Underscore: return(text.Underscore());

            default: return(text);
            }
        }
        public async Task TestReceivingTimeouts(ConventionType seedType)
        {
            using (var db = new ReusableDB())
            {
                string prefillIndex;

                using (var store = db.NewStore())
                {
                    ApplyPrefillConventions(store, seedType);
                    store.Initialize();

                    await Prefill(store, seedType);

                    prefillIndex = CreateTimeoutIndex(store);
                }

                // Need to ensure multiple runs will work, after conventions document is stored
                for (var i = 0; i < 3; i++)
                {
                    using (var store = db.NewStore())
                    {
                        Console.WriteLine($"Testing receives with DocumentStore initially configured for {seedType} conventions.");
                        ApplyTestConventions(store, seedType);
                        store.Initialize();

                        var index = CreateTimeoutIndex(store);
                        db.WaitForIndexing(store);

                        Assert.AreEqual(index, prefillIndex, "Index definitions must match or previous timeouts will not be found.");

                        var query = new QueryTimeouts(store, EndpointName);
                        var chunkTuples = (await query.GetNextChunk(DateTime.UtcNow.AddYears(-10))).DueTimeouts.ToArray();

                        Assert.AreEqual(10, chunkTuples.Length);
                        foreach (var tuple in chunkTuples)
                        {
                            Console.WriteLine($"Received timeout {tuple.Id}");
                            Assert.AreEqual(dueTimeout, tuple.DueTime);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// AttributeConvention -> NamingPolicy
        /// </summary>
        /// <param name="api"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        private string ProcessConvention(object api, ParameterData param)
        {
            string output = param.name;

            if (param.requestAttribute != null &&
                Conv(param.requestAttribute.convention, param.name, out output))
            {
                return(output);
            }

            var policy = (NamingPolicy)api
                         .GetType()
                         .GetProperty(nameof(WithNamingPolicy.namingPolicy))
                         .GetValue(api);
            ConventionType convention = ConventionType.None;

            switch (param.type)
            {
            case ParameterType.PostJson:
                convention = policy.postJson;
                break;

            case ParameterType.Header:
                convention = policy.header;
                break;

            case ParameterType.RequestUri:
                convention = policy.requestUri;
                break;
            }

            if (Conv(convention, param.name, out output))
            {
                return(output);
            }

            return(param.name);
        }
        public async Task TestMarkingAsComplete(ConventionType seedType)
        {
            using (var db = new ReusableDB())
            {
                List<TestSagaData> sagas;

                using (var store = db.NewStore())
                {
                    ApplyPrefillConventions(store, seedType);
                    store.Initialize();

                    sagas = await Prefill(store, seedType);
                }

                using (var store = db.NewStore())
                {
                    Console.WriteLine($"Testing saga lookups with DocumentStore initially configured for {seedType} conventions.");
                    ApplyTestConventions(store, seedType);
                    store.Initialize();

                    // Update each saga, once by id and once by correlation property
                    foreach (var saga in sagas)
                    {
                        var persister = new SagaPersister();
                        using (var session = store.OpenAsyncSession())
                        {
                            Console.WriteLine($"Retrieving SagaId {saga.Id} by Correlation Property OrderId={saga.OrderId} and completing.");
                            var ravenDBSynchronizedStorageSession = new RavenDBSynchronizedStorageSession(session, false);
                            var contextBag = new ContextBag();
                            var byOrderId = await persister.Get<TestSagaData>("OrderId", saga.OrderId, ravenDBSynchronizedStorageSession, contextBag);
                            Assert.IsNotNull(byOrderId);

                            await persister.Complete(byOrderId, ravenDBSynchronizedStorageSession, contextBag);
                            await session.SaveChangesAsync();
                        }
                    }

                    db.WaitForIndexing(store);

                    // Ensure terms are still the saga type and unique identity type
                    var terms = store.DatabaseCommands.GetTerms("Raven/DocumentsByEntityName", "Tag", null, 1024).ToList();
                    Assert.AreEqual(2, terms.Count);

                    foreach (var term in terms)
                    {
                        var query = new IndexQuery
                        {
                            Query = "Tag:" + term,
                            PageSize = 0
                        };

                        // Ensure there are none left
                        var queryResult = store.DatabaseCommands.Query("Raven/DocumentsByEntityName", query);
                        Assert.AreEqual(0, queryResult.TotalResults);
                    }
                }
            }
        }
Пример #13
0
 /// <summary>
 /// Helper method that builds a template target.
 /// </summary>
 /// <param name="operation">The target operation.</param>
 /// <param name="outputDirectory">The output directory for the file.</param>
 /// <param name="template">The template to use.</param>
 protected void BuildOperation(Operation operation, string outputDirectory, ITemplate template, ConventionType format = ConventionType.PascalCase)
 {
     template.TargetOperation = operation;
     File.WriteAllText(
         Path.Combine(outputDirectory, operation.Name.Convention(format) + this.Extension),
         template.AsText(this.Indent)
         );
     template.Clear();
 }
Пример #14
0
 /// <summary>
 /// Helper method that builds a template target.
 /// </summary>
 /// <param name="type">The target type.</param>
 /// <param name="outputDirectory">The output directory for the file.</param>
 /// <param name="template">The template to use.</param>
 protected void BuildType(CustomType type, string outputDirectory, ITemplate template, ConventionType format = ConventionType.PascalCase)
 {
     template.TargetType = type;
     File.WriteAllText(
         Path.Combine(outputDirectory, type.Name.Convention(format) + this.Extension),
         template.AsText(this.Indent)
         );
     template.Clear();
 }
Пример #15
0
 /// <summary>
 /// Helper method that builds a template target.
 /// </summary>
 /// <param name="operation">The target operation.</param>
 /// <param name="outputDirectory">The output directory for the file.</param>
 /// <param name="template">The template to use.</param>
 protected void BuildOperation(Operation operation, string outputDirectory, ITemplate template, ConventionType format = ConventionType.PascalCase)
 {
     template.TargetOperation = operation;
     File.WriteAllText(
         Path.Combine(outputDirectory, operation.Name.Convention(format) + this.Extension),
         template.AsText(this.Indent)
         );
     template.Clear();
 }
        public async Task EnsureOldAndNewTimeoutsCanBeReceived(ConventionType seedType)
        {
            using (var db = new ReusableDB())
            {
                using (var store = db.NewStore())
                {
                    ApplyPrefillConventions(store, seedType);
                    store.Initialize();

                    await Prefill(store, seedType);
                }

                using (var store = db.NewStore())
                {
                    ApplyTestConventions(store, seedType);
                    store.Initialize();

                    CreateTimeoutIndex(store);

                    var persister = new TimeoutPersister(store);
                    
                    for (var i = 1; i <= 10; i++)
                    {
                        await persister.Add(new TimeoutData
                        {
                            Destination = EndpointName,
                            Headers = new Dictionary<string, string>(),
                            OwningTimeoutManager = EndpointName,
                            SagaId = Guid.NewGuid(),
                            Time = dueTimeout
                        }, new ContextBag());
                    }

                    db.WaitForIndexing(store);

                    var query = new QueryTimeouts(store, EndpointName);
                    var chunkTuples = (await query.GetNextChunk(DateTime.UtcNow.AddYears(-10))).DueTimeouts.ToArray();

                    Assert.AreEqual(20, chunkTuples.Length);
                    foreach (var tuple in chunkTuples)
                    {
                        Console.WriteLine($"Received timeout {tuple.Id}");
                        Assert.AreEqual(dueTimeout, tuple.DueTime);
                    }
                }
            }
        }
Пример #17
0
 /// <summary>
 /// Helper method that builds a template target.
 /// </summary>
 /// <param name="target">The target name.</param>
 /// <param name="outputDirectory">The output directory for the file.</param>
 /// <param name="template">The template to use.</param>
 protected void BuildTarget(string target, string outputDirectory, ITemplate template, ConventionType format = ConventionType.PascalCase)
 {
     template.Target = target;
     File.WriteAllText(
         Path.Combine(outputDirectory, target.Convention(format) + this.Extension),
         template.AsText(this.Indent)
         );
     template.Clear();
 }
 public RequestUri(ConventionType convention)
 {
     this.convention = convention;
 }
Пример #19
0
 /// <summary>
 /// Helper method that builds a template target.
 /// </summary>
 /// <param name="target">The target name.</param>
 /// <param name="outputDirectory">The output directory for the file.</param>
 /// <param name="template">The template to use.</param>
 protected void BuildTarget(string target, string outputDirectory, ITemplate template, ConventionType format = ConventionType.PascalCase )
 {
     template.Target = target;
     File.WriteAllText(
         Path.Combine(outputDirectory, target.Convention(format) + this.Extension),
         template.AsText(this.Indent)
         );
     template.Clear();
 }
Пример #20
0
 /// <summary>
 /// Helper method that builds a template target.
 /// </summary>
 /// <param name="type">The target type.</param>
 /// <param name="outputDirectory">The output directory for the file.</param>
 /// <param name="template">The template to use.</param>
 protected void BuildType(CustomType type, string outputDirectory, ITemplate template, ConventionType format = ConventionType.PascalCase)
 {
     template.TargetType = type;
     File.WriteAllText(
         Path.Combine(outputDirectory, type.Name.Convention(format) + this.Extension),
         template.AsText(this.Indent)
         );
     template.Clear();
 }
Пример #21
0
 public string GetNamingConvention(string name, ConventionType conventionType)
 {
     return(string.Empty);
 }
        private async Task<List<TestSagaData>> Prefill(IDocumentStore store, ConventionType seedType)
        {
            var snooper = StoreSnooper.Install(store);

            Console.WriteLine($"Filling database with saga data, using {seedType} conventions");

            var names = new Dictionary<ConventionType, string>
            {
                {ConventionType.RavenDefault, "TestSagaDatas"},
                {ConventionType.NSBDefault, "TestSaga"},
                {ConventionType.Customer, "ataDagaStseT"}
            };
            var name = names[seedType];

            var sagas = Enumerable.Range(1001, 10)
                .Select(orderId => new TestSagaData
                {
                    Id = Guid.NewGuid(),
                    OrderId = orderId,
                    OriginalMessageId = Guid.NewGuid().ToString(),
                    Originator = "SomeSaga",
                    Counter = 1
                })
                .ToList();


            foreach (var saga in sagas)
            {
                snooper.Clear();

                var persister = new SagaPersister();

                Console.WriteLine($"Storing SagaId {saga.Id}");
                using (var session = store.OpenAsyncSession())
                {
                    await persister.Save(saga, new SagaCorrelationProperty("OrderId", saga.OrderId), new RavenDBSynchronizedStorageSession(session, false), null);
                    await session.SaveChangesAsync();
                }
                var keysStored = snooper.KeysStored.ToList();

                foreach (var key in keysStored)
                {
                    Console.WriteLine($"  * Document created: {key}");
                }

                Assert.AreEqual(2, snooper.KeyCount);
                Assert.Contains($"{name}/{saga.Id}", keysStored);
            }

            return sagas;
        }
        public async Task TestStoringSagas(ConventionType seedType)
        {
            using (var db = new ReusableDB())
            {
                List <TestSagaData> sagas;

                using (var store = db.NewStore())
                {
                    ApplyPrefillConventions(store, seedType);
                    store.Initialize();

                    sagas = await Prefill(store, seedType);
                }

                using (var store = db.NewStore())
                {
                    Console.WriteLine($"Testing saga updates with DocumentStore initially configured for {seedType} conventions.");
                    ApplyTestConventions(store, seedType);
                    store.Initialize();

                    // Update each saga, once by id and once by correlation property
                    foreach (var saga in sagas)
                    {
                        var persister = new SagaPersister();
                        Console.WriteLine($"Retrieving SagaId {saga.Id} by SagaId");
                        using (var session = store.OpenAsyncSession())
                        {
                            var ravenDBSynchronizedStorageSession = new RavenDBSynchronizedStorageSession(session, false);
                            var byId = await persister.Get <TestSagaData>(saga.Id, ravenDBSynchronizedStorageSession, null);

                            Assert.IsNotNull(byId);

                            byId.Counter++;
                            await persister.Update(byId, ravenDBSynchronizedStorageSession, null);

                            await session.SaveChangesAsync();

                            Console.WriteLine($"Retrieving SagaId {saga.Id} by Correlation Property OrderId={saga.OrderId}");
                            var byOrderId = await persister.Get <TestSagaData>("OrderId", saga.OrderId, ravenDBSynchronizedStorageSession, new ContextBag());

                            Assert.IsNotNull(byOrderId);

                            byOrderId.Counter++;
                            await persister.Update(byOrderId, ravenDBSynchronizedStorageSession, null);

                            await session.SaveChangesAsync();
                        }
                    }

                    Console.WriteLine("Retrieving each saga again by SagaId and making sure Counter == 3");
                    foreach (var saga in sagas)
                    {
                        var persister = new SagaPersister();
                        using (var session = store.OpenAsyncSession())
                        {
                            Console.WriteLine($"Retrieving SagaId {saga.Id} by SagaId");
                            var byId = await persister.Get <TestSagaData>(saga.Id, new RavenDBSynchronizedStorageSession(session, false), null);

                            Assert.IsNotNull(byId);
                            Assert.AreEqual(3, byId.Counter);
                        }
                    }
                }
            }
        }
 public PostJson(ConventionType convention)
 {
     this.convention = convention;
 }
        private async Task Prefill(IDocumentStore store, ConventionType seedType)
        {
            Console.WriteLine($"Filling database with timeout data, using {seedType} conventions");
            var timeout = new TimeoutData
            {
                Destination = EndpointName,
                Headers = new Dictionary<string, string>(),
                OwningTimeoutManager = EndpointName,
                Time = new DateTime(DateTime.UtcNow.Year, 1, 1)
            };

            var names = new Dictionary<ConventionType, string>
            {
                { ConventionType.RavenDefault, "TimeoutDatas" },
                { ConventionType.NSBDefault, "TimeoutData" },
                { ConventionType.Customer, "ataDtuoemiT" }
            };
            var name = names[seedType];

            for (var i = 1; i <= 10; i++)
            {
                await DirectStore(store, $"{name}/{i}", timeout, name);
            }

            await StoreHiLo(store, name);
        }
 public Header(ConventionType convention)
 {
     this.convention = convention;
 }
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 public RelationalMappingConventionDefault(ConventionType type, bool usePluralTableNames)
 {
     _usePluralTableNames = usePluralTableNames;
     _type = type;
 }