コード例 #1
0
        public void CanGetEmptyCollection()
        {
            using (var store = NewDocumentStore())
            {
                new CasinosSuspensionsIndex().Execute(store);

                using (var documentSession = store.OpenSession())
                {
                    var casino = new Casino("cities/1", "address", "name")
                    {
                        Suspensions = new List <Suspension>()
                        {
                            new Suspension(DateTime.UtcNow, new List <Exemption>())
                        }
                    };
                    documentSession.Store(casino);
                    documentSession.SaveChanges();

                    var suspensions = documentSession.Query <CasinosSuspensionsIndex.IndexResult, CasinosSuspensionsIndex>().
                                      Customize(x => x.WaitForNonStaleResults()).
                                      Where(x => x.CityId == "cities/1").
                                      OrderByDescending(x => x.DateTime).
                                      Take(10).
                                      AsProjection <CasinosSuspensionsIndex.IndexResult>().
                                      ToList();

                    Assert.True(suspensions.All(x => x.Exemptions != null));
                }
            }
        }
コード例 #2
0
ファイル: IdsaTest.cs プロジェクト: itmeze/ravendb
        public void CanGetEmptyCollection()
        {
            using (var store = NewDocumentStore())
            {
                new CasinosSuspensionsIndex().Execute(store);

                using (var documentSession = store.OpenSession())
                {
                    var casino = new Casino("cities/1", "address", "name")
                    {
                        Suspensions = new List <Suspension>()
                        {
                            new Suspension(DateTime.UtcNow, new List <Exemption>())
                        }
                    };
                    documentSession.Store(casino);
                    documentSession.SaveChanges();

                    var suspensions = documentSession.Query <CasinosSuspensionsIndex.IndexResult, CasinosSuspensionsIndex>().
                                      Customize(x => x.WaitForNonStaleResults()).
                                      Where(x => x.CityId == "cities/1").
                                      OrderByDescending(x => x.DateTime).
                                      Take(10).
                                      AsProjection <CasinosSuspensionsIndex.IndexResult>().
                                      ToList();

                    // note that suspensions[0].Exemptions will be null, because we don't have
                    // any values in the array, and we don't store empty arrays
                    Assert.NotEmpty(suspensions);
                }
            }
        }