示例#1
0
文件: Fixture.cs 项目: jrauber/GH1429
        public void ProxiesFromDeserializedSessionsCanBeLoaded()
        {
            MemoryStream sessionMemoryStream;

            using (ISession s = Sfi.OpenSession())
            {
                using (ITransaction t = s.BeginTransaction())
                {
                    Entity1 e = s.Get <Entity1>(_id);
                    t.Commit();
                }

                sessionMemoryStream = new MemoryStream();
                BinaryFormatter writer = new BinaryFormatter();
                writer.Serialize(sessionMemoryStream, s);
            }

            sessionMemoryStream.Seek(0, SeekOrigin.Begin);
            BinaryFormatter reader          = new BinaryFormatter();
            ISession        restoredSession = (ISession)reader.Deserialize(sessionMemoryStream);

            Entity1 e1 = restoredSession.Get <Entity1>(_id);
            Entity2 e2 = e1.Entity2;

            Assert.IsNotNull(e2);
            Assert.AreEqual("Text", e2.Text);

            restoredSession.Dispose();
        }
        public async Task ProxiesFromDeserializedSessionsCanBeLoadedAsync()
        {
            TestsContext.AssumeSystemTypeIsSerializable();

            MemoryStream sessionMemoryStream;

            using (ISession s = Sfi.OpenSession())
            {
                using (ITransaction t = s.BeginTransaction())
                {
                    Entity1 e = await(s.GetAsync <Entity1>(_id));
                    await(t.CommitAsync());
                }

                sessionMemoryStream = new MemoryStream();
                BinaryFormatter writer = new BinaryFormatter();
                writer.Serialize(sessionMemoryStream, s);
            }

            sessionMemoryStream.Seek(0, SeekOrigin.Begin);
            BinaryFormatter reader          = new BinaryFormatter();
            ISession        restoredSession = (ISession)reader.Deserialize(sessionMemoryStream);

            Entity1 e1 = await(restoredSession.GetAsync <Entity1>(_id));
            Entity2 e2 = e1.Entity2;

            Assert.IsNotNull(e2);
            Assert.AreEqual("Text", e2.Text);

            restoredSession.Dispose();
        }
示例#3
0
		protected override void OnSetUp()
		{
			using (ISession s = sessions.OpenSession())
			{
				using (ITransaction t = s.BeginTransaction())
				{
					Entity1 e1 = new Entity1();
					Entity2 e2 = new Entity2();
					e1.Entity2 = e2;
					e2.Text = "Text";

					s.Save(e1);
					s.Save(e2);

					_id = e1.Id;

					t.Commit();
				}
			}
		}
示例#4
0
文件: Fixture.cs 项目: jrauber/GH1429
        protected override void OnSetUp()
        {
            using (ISession s = Sfi.OpenSession())
            {
                using (ITransaction t = s.BeginTransaction())
                {
                    Entity1 e1 = new Entity1();
                    Entity2 e2 = new Entity2();
                    e1.Entity2 = e2;
                    e2.Text    = "Text";

                    s.Save(e1);
                    s.Save(e2);

                    _id = e1.Id;

                    t.Commit();
                }
            }
        }
示例#5
0
        public async Task ProxiesFromDeserializedSessionsCanBeLoadedAsync()
        {
            MemoryStream sessionMemoryStream;

            using (ISession s = Sfi.OpenSession())
            {
                using (ITransaction t = s.BeginTransaction())
                {
                    Entity1 e = await(s.GetAsync <Entity1>(_id));
                    await(t.CommitAsync());
                }

                sessionMemoryStream = new MemoryStream();
                var writer = new BinaryFormatter
                {
#if !NETFX
                    SurrogateSelector = new SerializationHelper.SurrogateSelector()
#endif
                };
                writer.Serialize(sessionMemoryStream, s);
            }

            sessionMemoryStream.Seek(0, SeekOrigin.Begin);
            var reader = new BinaryFormatter
            {
#if !NETFX
                SurrogateSelector = new SerializationHelper.SurrogateSelector()
#endif
            };
            ISession restoredSession = (ISession)reader.Deserialize(sessionMemoryStream);

            Entity1 e1 = await(restoredSession.GetAsync <Entity1>(_id));
            Entity2 e2 = e1.Entity2;

            Assert.IsNotNull(e2);
            Assert.AreEqual("Text", e2.Text);

            restoredSession.Dispose();
        }