Esempio n. 1
0
 public void AssertCorrectContents_correctly_identifies_ToStream_result()
 {
     TestObjClassSerializationMock.ToStream <LocalMock, TestEnum>(sw, iftFactory);
     ms.Seek(0, SeekOrigin.Begin);
     TestObjClassSerializationMock.AssertCorrectContents <LocalMock, TestEnum>(sr, iftFactory);
     Assert.That(ms.Position, Is.EqualTo(ms.Length), "AssertCorrectContents didn't read complete stream");
 }
Esempio n. 2
0
        public void FromStream_creates_correct_Object()
        {
            var typeMap = scope.Resolve <TypeMap>();
            var ms      = new MemoryStream();
            var sw      = new ZetboxStreamWriter(typeMap, new BinaryWriter(ms));
            var sr      = new ZetboxStreamReader(typeMap, new BinaryReader(ms));

            TestObjClassSerializationMock.ToStream <TestObjClass, TestEnum>(sw, _iftFactory);
            sw.Flush();

            Assert.That(ms.Length, Is.GreaterThan(0));
            ms.Seek(0, SeekOrigin.Begin);

            var t = sr.ReadSerializableType();

            Assert.That(t.GetSystemType().IsAssignableFrom(typeof(TestObjClass)), string.Format("{0} not assignable to {1}", typeof(TestObjClass), t));

            var obj = new TestObjClassImpl();

            obj.FromStream(sr);
            ctx.Attach(obj);

            TestObjClassSerializationMock.AssertCorrectContentsEnum <TestObjClass>(obj);
        }