Example #1
0
        public async Task CanUpdatePatternFieldInIndexDefinitionSoItWillAffectReferenceDocuments()
        {
            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    PutOrders(session);

                    session.SaveChanges();
                }

                new Orders_ProfitByProductAndOrderedAt().Execute(store);

                WaitForIndexing(store);

                WaitForUserToContinueTheTest(store);

                await store.ExecuteIndexAsync(new Replacement_PatternFieldUpdate.Orders_ProfitByProductAndOrderedAt());

                WaitForIndexing(store);

                WaitForUserToContinueTheTest(store);

                using (var session = store.OpenSession())
                {
                    var doc = session.Load <OutputReduceToCollectionReference>("reports/daily/2020-01-01", x => x.IncludeDocuments(y => y.ReduceOutputs));

                    Assert.Equal(2, doc.ReduceOutputs.Count);

                    foreach (var docReduceOutput in doc.ReduceOutputs)
                    {
                        Replacement.Orders_ProfitByProductAndOrderedAt.Result output = session.Load <Replacement.Orders_ProfitByProductAndOrderedAt.Result>(docReduceOutput);

                        Assert.NotNull(output);
                    }

                    int count = session.Advanced.RawQuery <object>("from 'Profits/References'").Count();

                    Assert.Equal(1, count);
                }
            }
        }
Example #2
0
        public async Task CanUpdatePatternForOutputReduceToCollection()
        {
            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    PutOrders(session);

                    session.SaveChanges();
                }

                new Orders_ProfitByProductAndOrderedAt().Execute(store);

                Indexes.WaitForIndexing(store);

                await store.ExecuteIndexAsync(new Replacement_DifferentPattern.Orders_ProfitByProductAndOrderedAt());

                Indexes.WaitForIndexing(store);

                using (var session = store.OpenSession())
                {
                    var doc = session.Load <OutputReduceToCollectionReference>("reports/monthly/2019-10", x => x.IncludeDocuments(y => y.ReduceOutputs));

                    Assert.Equal(4, doc.ReduceOutputs.Count);

                    foreach (var docReduceOutput in doc.ReduceOutputs)
                    {
                        Replacement.Orders_ProfitByProductAndOrderedAt.Result output = session.Load <Replacement.Orders_ProfitByProductAndOrderedAt.Result>(docReduceOutput);

                        Assert.NotNull(output);
                    }

                    int count = session.Advanced.RawQuery <object>("from 'Profits/References'").Count();

                    Assert.Equal(1, count);
                }
            }
        }