Example #1
0
        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();
        }
Example #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();
				}
			}
		}
Example #4
0
        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();
                }
            }
        }
Example #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();
        }