Exemplo n.º 1
0
        public void Can_convert_stored_null_value_and_empty_string(string str)
        {
            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    var otherEnt = new OtherEnt("test1");
                    session.Store(otherEnt);

                    session.Store(new Ent1(otherEnt.Id, 1, EnumTest.Item1, str));
                    session.Store(new Ent2(otherEnt.Id, 2, EnumTest.Item2, str));
                    session.SaveChanges();
                }

                new SampleIndex().Execute(store);
                WaitForIndexing(store);

                using (var session = store.OpenSession())
                {
                    var list = (from r in session.Query <SampleIndex.Result, SampleIndex>()
                                let other = RavenQuery.Load <OtherEnt>(r.IdOtherEnt)
                                            select new SampleDto2
                    {
                        Id = r.Id,
                        NameOtherEnt = other.Name,
                        PropBase = r.PropBase,
                        Prop1 = r.Prop1,
                        Prop2 = r.Prop2,
                        Str = r.Str
                    }).ToList();

                    Assert.Equal(2, list.Count);

                    Assert.Equal(1, list[0].PropBase);
                    Assert.Equal(EnumTest.Item1, list[0].Prop1);
                    Assert.Equal(null, list[0].Prop2);
                    Assert.Equal(str, list[0].Str);

                    Assert.Equal(2, list[1].PropBase);
                    Assert.Equal(null, list[1].Prop1);
                    Assert.Equal(EnumTest.Item2, list[1].Prop2);
                    Assert.Equal(str, list[1].Str);
                }
            }
        }
Exemplo n.º 2
0
        public void Can_convert_store_and_get_null_value_and_empty_string(string str)
        {
            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    var otherEnt = new OtherEnt("test1");
                    session.Store(otherEnt);

                    session.Store(new Ent1(otherEnt.Id, 1, EnumTest.Item1, str));
                    session.Store(new Ent2(otherEnt.Id, 2, EnumTest.Item2, str));
                    session.SaveChanges();
                }

                new SampleIndex().Execute(store);
                WaitForIndexing(store);

                using (var session = store.OpenSession())
                {
                    var list = session.Query <SampleIndex.Result, SampleIndex>()
                               .ProjectInto <SampleDto>()
                               .ToList();

                    Assert.Equal(2, list.Count);

                    Assert.Equal(1, list[0].PropBase);
                    Assert.Equal(EnumTest.Item1, list[0].Prop1);
                    Assert.Equal(null, list[0].Prop2);
                    Assert.Equal(str, list[0].Str);

                    Assert.Equal(2, list[1].PropBase);
                    Assert.Equal(null, list[1].Prop1);
                    Assert.Equal(EnumTest.Item2, list[1].Prop2);
                    Assert.Equal(str, list[0].Str);
                }
            }
        }