public void ConstructorSetsProperties()
        {
            ASExternalizableObject obj = new ASExternalizableObject(externalizableClass, externalizable);

            Assert.AreSame(externalizableClass, obj.Class);
            Assert.AreSame(externalizable, obj.ExternalizableValue);
        }
        public void WriteObject_Objects_Externalizable_AMF3()
        {
            IExternalizable externalizableValue = Mocks.CreateMock<IExternalizable>();
            externalizableValue.WriteExternal(output);
            LastCall.Do((WriteExternalDelegate)delegate(IDataOutput outputToUse)
            {
                // Note: outputToUse will be the same instance as output which we've already
                // tested so we don't need to try all combinations here.  Just a few as a sanity check.
                outputToUse.WriteUTF("abc");
                outputToUse.WriteInt(10);
                outputToUse.WriteObject(new ASString("def"));
            });

            ASClass @class = new ASClass("class", ASClassLayout.Externalizable, EmptyArray<string>.Instance);
            ASExternalizableObject obj = new ASExternalizableObject(@class, externalizableValue);

            Mocks.ReplayAll();

            output.ObjectEncoding = AMFObjectEncoding.AMF3;
            output.BeginObjectStream();
            output.WriteObject(obj);
            output.EndObjectStream();

            byte[] expected = new byte[] { (byte)AMF0ObjectTypeCode.AMF3Data, (byte)AMF3ObjectTypeCode.Object, 0x07,
                0x0b, 0x63, 0x6c, 0x61, 0x73, 0x73, // class def
                0x00, 0x03, 0x61, 0x62, 0x63, // write utf "abc"
                0x00, 0x00, 0x00, 0x0a, // write int 10
                (byte) AMF3ObjectTypeCode.String, 0x07, 0x64, 0x65, 0x66 // write object "def"
            };

            CollectionAssert.AreElementsEqual(expected, stream.ToArray());
        }
        public void SetPropertiesWithInitializedInstanceThrows()
        {
            IExternalizable externalizableValue = Mocks.CreateMock<IExternalizable>();
            Mocks.ReplayAll();

            ASExternalizableObject obj = new ASExternalizableObject(externalizableClass, externalizableValue);
            obj.SetProperties(externalizableValue);
        }