Exemplo n.º 1
0
        public void Run()
        {
            using (var documentStore = GetDocumentStore())
            {
                using (var documentSession = documentStore.OpenSession())
                {
                    var cgc = new Cgc {
                        Name = "Cgc"
                    };
                    documentSession.Store(cgc);

                    var production = new Production {
                        Name = "Production", CgcId = cgc.Id
                    };
                    documentSession.Store(production);

                    var cgc2 = new Cgc {
                        Name = "TwoCgc"
                    };
                    documentSession.Store(cgc2);

                    var production2 = new Production {
                        Name = "TwoProduction", CgcId = cgc2.Id
                    };
                    documentSession.Store(production2);

                    documentSession.SaveChanges();
                }

                new CgcAndProductionIndex().Execute(documentStore);
                WaitForIndexing(documentStore);

                using (var documentSession = documentStore.OpenSession())
                {
                    var results = documentSession
                                  .Query <CgcAndProduction, CgcAndProductionIndex>()
                                  .Customize(x => x.WaitForNonStaleResults())
                                  .Where(x => x.CgcName == "TwoCgc" && x.ProductionName == "TwoProduction")
                                  .ToList();

                    Assert.Equal(1, results.Count);
                }
            }
        }
Exemplo n.º 2
0
 public override string ToString()
 {
     return($"Cliente:\t{Nome.Trim()}\tCPF:\t{Cgc.Trim()}");
 }