Esempio n. 1
0
        public async System.Threading.Tasks.Task InsertShouldNotDependOnEntityEqualsImplementationAsync()
        {
            var person = new PersonWithWrongEquals {
                Name = "AnimalOwner"
            };

            using (var s = OpenSession())
                using (var t = s.BeginTransaction())
                {
                    await(s.SaveAsync(person));
                    await(t.CommitAsync());
                }
            await(Sfi.EvictAsync(typeof(PersonWithWrongEquals)));

            using (var s = OpenSession())
                using (var t = s.BeginTransaction())
                {
                    var personProxy = await(s.GetAsync <PersonWithWrongEquals>(person.Id));

                    await(s.SaveAsync(new Cat {
                        Name = "Felix", Owner = personProxy
                    }));
                    await(s.SaveAsync(new Cat {
                        Name = "Loustic", Owner = personProxy
                    }));
                    Assert.DoesNotThrowAsync(() => { return(t.CommitAsync()); });
                }
        }
Esempio n. 2
0
        public void InsertShouldNotDependOnEntityEqualsImplementation()
        {
            var person = new PersonWithWrongEquals {
                Name = "AnimalOwner"
            };

            using (var s = OpenSession())
                using (var t = s.BeginTransaction())
                {
                    s.Save(person);
                    t.Commit();
                }
            Sfi.Evict(typeof(PersonWithWrongEquals));

            using (var s = OpenSession())
                using (var t = s.BeginTransaction())
                {
                    var personProxy = s.Get <PersonWithWrongEquals>(person.Id);

                    s.Save(new Cat {
                        Name = "Felix", Owner = personProxy
                    });
                    s.Save(new Cat {
                        Name = "Loustic", Owner = personProxy
                    });
                    Assert.DoesNotThrow(() => { t.Commit(); });
                }
        }