Exemple #1
0
        public void RemotingResultTest()
        {
            QuicklySerializer ser = new QuicklySerializer();
            var b = new Result <TestModel>()
            {
                Value = new TestModel()
                {
                    Id = "1", Name = "2"
                }
            };
            RemotingResult rb = new RemotingResult();

            rb.Value = new object[2] {
                b, null
            };
            var bytes = ser.FastWriteBytes(rb);
            var ra    = ser.FastReadBytes <RemotingResult>(bytes);

            Assert.NotNull(ra.Value);
            Assert.True(ra.Value is object[]);

            var a = (ra.Value as object[])[0] as Result <TestModel>;

            Assert.NotNull(ra);
            Assert.True(a.IsSucceed);
            Assert.NotNull(a.Value);
            Assert.Equal(b.Value.Id, a.Value.Id);
            Assert.Equal(b.Value.Name, a.Value.Name);
        }
Exemple #2
0
        public void TestMethod1()
        {
            TestClass1 tc1 = new TestClass1()
            {
                MyProperty = 564
            };

            tc1.TestClass2Property = new TestClass2()
            {
                TestClass1Property    = tc1,
                IntProperty           = 5,
                GuidProperty          = Guid.NewGuid(),
                DateTimeProperty      = DateTime.Now,
                StringBuilderProperty = new StringBuilder("adfdsfas")
            };


            QuicklySerializer ser = new QuicklySerializer();
            var bytes             = ser.FastWriteBytes(tc1);
            var tc2 = ser.FastReadBytes <TestClass1>(bytes);

            Assert.Equal(tc1.MyProperty, tc2.MyProperty);
            Assert.NotNull(tc2.TestClass2Property);
            Assert.Equal(tc1.TestClass2Property.TestClass1Property, tc1);
            Assert.Equal(tc1.TestClass2Property.IntProperty, tc2.TestClass2Property.IntProperty);
            Assert.Equal(tc1.TestClass2Property.GuidProperty, tc2.TestClass2Property.GuidProperty);
            Assert.Equal(tc1.TestClass2Property.DateTimeProperty, tc2.TestClass2Property.DateTimeProperty);
            Assert.Equal(tc1.TestClass2Property.StringBuilderProperty.ToString(), tc2.TestClass2Property.StringBuilderProperty.ToString());
        }
Exemple #3
0
        public void ProtectedTest()
        {
            QuicklySerializer ser = new QuicklySerializer();
            var bytes             = ser.FastWriteBytes(Result.Successfully);
            var result            = ser.FastReadBytes(bytes) as Result;

            Assert.NotNull(result);
        }
Exemple #4
0
        public void TimeSpanTest()
        {
            QuicklySerializer ser = new QuicklySerializer();
            TimeSpan          b   = new TimeSpan(1, 2, 3, 4);
            var bytes             = ser.FastWriteBytes(b);
            var a = ser.FastReadBytes <TimeSpan>(bytes);

            Assert.Equal(b, a);
        }
Exemple #5
0
        public void ResultTest1()
        {
            var m1 = new Result();
            QuicklySerializer ser = new QuicklySerializer();
            var m1_bytes          = ser.FastWriteBytes(m1);
            var m2 = ser.FastReadBytes <Result>(m1_bytes);

            Assert.Equal(m1.Status, m2.Status);
            Assert.Equal(m1.Exception, m2.Exception);
        }
Exemple #6
0
        public void ResultSuccessfullyTest()
        {
            var m1 = Result.Successfully;
            QuicklySerializer ser = new QuicklySerializer();
            var m1_bytes          = ser.FastWriteBytes(m1);

            Assert.Equal(1, m1_bytes.Length);
            var m2 = ser.FastReadBytes <Result>(m1_bytes);

            Assert.Equal(m1, m2);
        }
Exemple #7
0
        public void GResultTest2()
        {
            var m1 = new Result <int>().ToFailded("aaa", 100);
            QuicklySerializer ser = new QuicklySerializer();
            var m1_bytes          = ser.FastWriteBytes(m1);
            var m2 = ser.FastReadBytes <Result <int> >(m1_bytes);

            Assert.Equal(m1.Status, m2.Status);
            Assert.Equal(m1.Exception.Message, m1.Exception.Message);
            Assert.Equal(m1.Value, m2.Value);
        }
Exemple #8
0
        public void StructSTest()
        {
            QuicklySerializer ser = new QuicklySerializer();
            var point1            = new Point {
                X = 5, Y = 7
            };
            var bytes  = ser.FastWriteBytes(point1);
            var point2 = ser.FastReadBytes <Point>(bytes);

            Assert.Equal(point1.X, point2.X);
            Assert.Equal(point1.Y, point2.Y);
        }
Exemple #9
0
        public void CharArrayTest()
        {
            QuicklySerializer ser = new QuicklySerializer();
            var m1    = TestCl.Create();
            var bytes = ser.FastWriteBytes(m1);
            var m2    = ser.FastReadBytes <TestCl>(bytes);

            for (int i = 0; i < m1.SingleArrayOfChars.Length; i++)
            {
                Assert.Equal(m1.SingleArrayOfChars[i], m2.SingleArrayOfChars[i]);
            }
        }
Exemple #10
0
        public void NullableEnumTest()
        {
            TClas tc1 = new TClas()
            {
                Tse = (Tse)(-1)
            };
            QuicklySerializer ser = new QuicklySerializer();
            var bytes             = ser.FastWriteBytes(tc1);
            var tc2 = ser.FastReadBytes <TClas>(bytes);

            Assert.Equal(tc1.Tse, tc2.Tse);
        }
Exemple #11
0
        public void StructSTest2()
        {
            QuicklySerializer ser = new QuicklySerializer();
            var m1 = new EntryModel {
                hashCode = 44, key = 44, next = -1
            };
            var bytes = ser.FastWriteBytes(m1);
            var m2    = ser.FastReadBytes <EntryModel>(bytes);

            Assert.Equal(m1.hashCode, m2.hashCode);
            Assert.Equal(m1.key, m2.key);
            Assert.Equal(m1.next, m2.next);
        }
Exemple #12
0
        public void CustomFormatterTest1()
        {
            QuicklySerializer ser = new QuicklySerializer();

            var bytes = ser.FastWriteBytes(new CustomFormatter1()
            {
                Value = 501
            });
            var cf = ser.FastReadBytes <CustomFormatter1>(bytes);

            Assert.NotNull(cf);
            Assert.Equal(502, cf.Value);
        }
Exemple #13
0
        public void GResultTest1()
        {
            var m1 = new Result <int>()
            {
                Value = 333
            };
            QuicklySerializer ser = new QuicklySerializer();
            var m1_bytes          = ser.FastWriteBytes(m1);
            var m2 = ser.FastReadBytes <Result <int> >(m1_bytes);

            Assert.Equal(m1.Status, m2.Status);
            Assert.Equal(m1.Exception, m2.Exception);
            Assert.Equal(m1.Value, m2.Value);
        }
Exemple #14
0
        private T ObjectComparer <T>(T m1)
        {
            QuicklySerializer ser = new QuicklySerializer();
            var m1_bytes          = ser.FastWriteBytes(m1);
            var m2       = ser.FastReadBytes <T>(m1_bytes);
            var m2_bytes = ser.FastWriteBytes(m2);

            Assert.Equal(m1_bytes.Length, m2_bytes.Length);
            for (int i = 0; i < m1_bytes.Length; i++)
            {
                Assert.Equal(m1_bytes[i], m2_bytes[i]);
            }
            return(m2);
        }
Exemple #15
0
        public void TimeSpanArrayTest()
        {
            QuicklySerializer ser = new QuicklySerializer();

            TimeSpan[] b     = new TimeSpan[] { new TimeSpan(1, 2, 3, 4), new TimeSpan(1, 2, 3), new TimeSpan(125L), };
            var        bytes = ser.FastWriteBytes(b);
            var        a     = ser.FastReadBytes <TimeSpan[]>(bytes);

            Assert.NotNull(a);
            Assert.Equal(b.Length, a.Length);
            for (int i = 0; i < b.Length; i++)
            {
                Assert.Equal(b[i], a[i]);
            }
        }
Exemple #16
0
        public void CustomFormatterTest2()
        {
            QuicklySerializer ser = new QuicklySerializer();

            var bytes = ser.FastWriteBytes(new CustomFormatter2()
            {
                Value = new CustomFormatter2.Property()
                {
                    Value = 503
                }
            });
            var cf = ser.FastReadBytes <CustomFormatter2>(bytes);

            Assert.NotNull(cf);
            Assert.Equal(504, cf.Value.Value);
        }
Exemple #17
0
        public void ResultValueTest()
        {
            QuicklySerializer ser = new QuicklySerializer();
            var b = new Result <TestModel>();

            b.Value = new TestModel()
            {
                Id = "1", Name = "2"
            };
            var bytes = ser.FastWriteBytes(b);

            var a = ser.FastReadBytes <Result <TestModel> >(bytes);

            Assert.NotNull(a);
            Assert.True(a.IsSucceed);
            Assert.NotNull(a.Value);
            Assert.Equal(b.Value.Id, a.Value.Id);
            Assert.Equal(b.Value.Name, a.Value.Name);
        }