Ejemplo n.º 1
0
        public void CanBeUsedAsDiscriminator()
        {
            EnumCharFoo foo = new EnumCharFoo();
            EnumCharBar bar = new EnumCharBar();

            foo.Id = 1;
            bar.Id = 2;

            using (ISession s = OpenSession())
            {
                s.Save(foo);
                s.Save(bar);
                s.Flush();
            }

            using (ISession s = OpenSession())
            {
                s.Load <EnumCharFoo>(1);
                s.Load <EnumCharBar>(2);

                EnumCharBaz baz;

                baz = s.Load <EnumCharBaz>(1);
                Assert.AreEqual(SampleCharEnum.Dimmed, baz.Type);

                baz = s.Load <EnumCharBaz>(2);
                Assert.AreEqual(SampleCharEnum.Off, baz.Type);
            }
        }
Ejemplo n.º 2
0
        public async Task CanBeUsedAsDiscriminatorAsync()
        {
            EnumCharFoo foo = new EnumCharFoo();
            EnumCharBar bar = new EnumCharBar();

            foo.Id = 1;
            bar.Id = 2;

            using (ISession s = OpenSession())
            {
                await(s.SaveAsync(foo));
                await(s.SaveAsync(bar));
                await(s.FlushAsync());
            }

            using (ISession s = OpenSession())
            {
                await(s.LoadAsync <EnumCharFoo>(1));
                await(s.LoadAsync <EnumCharBar>(2));

                EnumCharBaz baz;

                baz = await(s.LoadAsync <EnumCharBaz>(1));
                Assert.AreEqual(SampleCharEnum.Dimmed, baz.Type);

                baz = await(s.LoadAsync <EnumCharBaz>(2));
                Assert.AreEqual(SampleCharEnum.Off, baz.Type);
            }
        }
		public void CanBeUsedAsDiscriminator()
		{
			EnumCharFoo foo = new EnumCharFoo();
			EnumCharBar bar = new EnumCharBar();

			foo.Id = 1;
			bar.Id = 2;

			using (ISession s = OpenSession())
			{
				s.Save(foo);
				s.Save(bar);
				s.Flush();
			}

			using (ISession s = OpenSession())
			{
				s.Load<EnumCharFoo>(1);
				s.Load<EnumCharBar>(2);

				EnumCharBaz baz;

				baz = s.Load<EnumCharBaz>(1);
				Assert.AreEqual(SampleCharEnum.Dimmed, baz.Type);

				baz = s.Load<EnumCharBaz>(2);
				Assert.AreEqual(SampleCharEnum.Off, baz.Type);
			}
		}