Esempio n. 1
0
        public void Stream()
        {
            var typeMap = scope.Resolve <TypeMap>();

            using (var ms = new MemoryStream())
                using (var sw = new ZetboxStreamWriter(typeMap, new BinaryWriter(ms)))
                    using (var sr = new ZetboxStreamReader(typeMap, new BinaryReader(ms)))
                    {
                        var ctx = GetContext();

                        ctx.Attach(obj);
                        obj.ToStream(sw, null, false);

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

                        ms.Seek(0, SeekOrigin.Begin);

                        var t = sr.ReadSerializableType();
                        Assert.That(t.GetSystemType().IsAssignableFrom(typeof(ANewObjectClass)), string.Format("{0} not assignable to {1}", typeof(ANewObjectClass), t));

                        BaseClientDataObjectMockImpl result = new BaseClientDataObjectMockImpl(null);
                        result.FromStream(sr);

                        Assert.That(result.GetType(), Is.EqualTo(obj.GetType()));
                        Assert.That(result.ID, Is.EqualTo(obj.ID));
                        Assert.That(result.ObjectState, Is.EqualTo(obj.ObjectState));
                    }
        }
Esempio n. 2
0
 public void FromStream_Null_StreamReader()
 {
     using (IZetboxContext ctx = GetContext())
     {
         BaseClientDataObjectMockImpl result = new BaseClientDataObjectMockImpl(null);
         result.FromStream((ZetboxStreamReader)null);
     }
 }
Esempio n. 3
0
        public override void SetUp()
        {
            base.SetUp();

            PropertyChangedCalled = false;

            obj = new BaseClientDataObjectMockImpl(null);
            obj.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(obj_PropertyChanged);
        }
Esempio n. 4
0
        public void ApplyChanges()
        {
            BaseClientDataObjectMockImpl result = new BaseClientDataObjectMockImpl(null);

            obj.SetPrivatePropertyValue <int>("ID", 10);

            obj.ApplyChangesFrom(result);
            Assert.That(result.ID, Is.EqualTo(obj.ID));
            Assert.That(PropertyChangedCalled, Is.True);
        }
Esempio n. 5
0
        public void ApplyChanges_Null()
        {
            BaseClientDataObjectMockImpl result = null;

            obj.ApplyChangesFrom(result);
        }