Example #1
0
        public void TestException()
        {
            VariantExceptionInfo x1 = new VariantExceptionInfo("type", "message", "source", "stacktrace");
            Variant v1 = new Variant(x1);

            byte[]  bytes = BinaryWriter.ToBytes(v1);
            Variant v2    = BinaryReader.FromBytes(bytes);

            Assert.AreEqual(Variant.EnumType.Exception, v2.Type);

            VariantExceptionInfo x2 = v2.AsException();

            Assert.AreEqual(x1.Class, x2.Class);
            Assert.AreEqual(x1.Message, x2.Message);
            Assert.AreEqual(x1.Source, x2.Source);
            Assert.AreEqual(x1.Stack, x2.Stack);
        }
Example #2
0
        public void TestExceptionBuffer()
        {
            VariantExceptionInfo x1 = new VariantExceptionInfo("type", "message", "source", "stacktrace");
            Variant v1 = new Variant(x1);

            var bufferSize = BinaryWriter.GetByteCount(v1);

            byte[] bytes = new byte[bufferSize];
            BinaryWriter.GetBytes(v1, BinaryMode.Default, bytes, 0);

            Variant v2 = BinaryReader.FromBytes(bytes);

            Assert.AreEqual(Variant.EnumType.Exception, v2.Type);

            VariantExceptionInfo x2 = v2.AsException();

            Assert.AreEqual(x1.Class, x2.Class);
            Assert.AreEqual(x1.Message, x2.Message);
            Assert.AreEqual(x1.Source, x2.Source);
            Assert.AreEqual(x1.Stack, x2.Stack);
        }