Esempio n. 1
0
        //public static void Main(string[] args)
        //{
        //    //KnownTypes.RegisterAssemblies(typeof(ReflectType2).GetTypeInfo().Assembly);
        //    //KnownTypes.RegisterAssemblies(typeof(Program).GetTypeInfo().Assembly);

        //    //RunSomeTests();
        //    RunAllTests();

        //    Console.WriteLine();
        //    Console.WriteLine("Done.");
        //    Console.ReadLine();
        //}

        public static void RunSomeTests()
        {
            //var tReg = new RegistryTests();
            //tReg.Create1();

            var tSer = new SerializationTests();

            //tSer.CheckIsSmall();
            //tSer.CheckGeneric();

            tSer.CheckComplexClass();
            tSer.CheckSimpleTypes();
        }
        private static List <BenchResult> RunTests(BenchTestObjectA instance)
        {
            List <BenchResult> results = new List <BenchResult>();
            IEnumerable <ISerializerAdapter> serializers = SerializationTests.GetSerializers()
                                                           .Select(t => (ISerializerAdapter)Activator.CreateInstance(t));

            foreach (var ser in serializers)
            {
                Console.WriteLine("Benchmarking {0}", ser.GetType().Name);
                var result = Benchmark.Run(ser, instance);
                results.Add(result);
            }
            return(results.OrderBy(r => r.Average.TotalTime).ToList());
        }
Esempio n. 3
0
        public void CircularCSharpClosure()
        {
            object[]        arr      = new object[] { 1, 2, 3 };
            Func <object[]> getArray = () => arr;

            arr[2] = getArray;
            foreach (var streamConstructors in SerializationTests.MemoryStreamConstructors)
            {
                var otherGetArray            = (Func <object[]>)SerializationTests.roundTrip(streamConstructors.Item1, streamConstructors.Item2, getArray);
                var otherGetArrayCircularRef = (Func <object[]>)(otherGetArray()[2]);
                Assert.AreEqual(getArray()[0], otherGetArray()[0]);
                Assert.AreEqual(getArray()[0], otherGetArrayCircularRef()[0]);
                Assert.AreSame(otherGetArray(), otherGetArrayCircularRef());
            }
        }