Exemple #1
0
//	    [TestMethod]
        public void TestAdvGenerics1()//ported from simplTranslators/test ecologylab.translators.java.generics.JavaTranslatorGenericTest.java
        {
            SimplTypesScope.EnableGraphSerialization();

            SimplTypesScope scope = SimplTypesScope.Get("test-adv-generics-1", typeof(SearchResult), typeof(Search <>), typeof(SocialSearchResult), typeof(SocialSearch), typeof(TypedSocialSearch <>));

            SimplTypesScope.DisableGraphSerialization();
        }
Exemple #2
0
//        [TestMethod]
        public void ContainerJson()
        {
            SimplTypesScope.EnableGraphSerialization();

            Container       test             = new Container().InitializeInstance();
            SimplTypesScope translationScope = SimplTypesScope.Get("testcollection", typeof(Container),
                                                                   typeof(ClassA));

            TestMethods.TestSimplObject(test, translationScope, Format.Json);


            SimplTypesScope.DisableGraphSerialization();
        }
Exemple #3
0
//        [TestMethod]
        public void ClassDJson()
        {
            SimplTypesScope.EnableGraphSerialization();

            ClassC classC = new ClassC();
            ClassD test   = new ClassD(new ClassA(classC), new ClassB(classC));

            SimplTypesScope tScope = SimplTypesScope.Get("classD", typeof(ClassA), typeof(ClassB),
                                                         typeof(ClassC), typeof(ClassD), typeof(ClassX));

            TestMethods.TestSimplObject(test, tScope, Format.Json);

            SimplTypesScope.DisableGraphSerialization();
        }
Exemple #4
0
        //        [TestMethod]
        public void ClassBJson()
        {
            SimplTypesScope.EnableGraphSerialization();

            ClassA test   = new ClassA(1, 2);
            ClassB classB = new ClassB(3, 4, test);

            test.ClassB = classB;

            SimplTypesScope tScope = SimplTypesScope.Get("classA", typeof(ClassA), typeof(ClassB));

            TestMethods.TestSimplObject(test, tScope, Format.Json);

            SimplTypesScope.DisableGraphSerialization();
        }
Exemple #5
0
        public void ClassBXml()
        {
            SimplTypesScope.EnableGraphSerialization();

            ClassB test   = new ClassB(1, 2);
            ClassA classA = new ClassA(3, 4, test);

            test.ClassA = classA;

            SimplTypesScope tScope = SimplTypesScope.Get("classB", typeof(ClassA), typeof(ClassB));

            TestMethods.TestSimplObject(test, tScope, Format.Xml);

            SimplTypesScope.DisableGraphSerialization();
        }
Exemple #6
0
        public void TestBasicGenerics()//ported from simplTranslators/test ecologylab.translators.java.generics.JavaTranslatorGenericTest.java
        {
            SimplTypesScope.EnableGraphSerialization();

            //My
            SimplTypesScope s = SimplTypesScope.Get("test_basic_generics", typeof(My <>));

            FieldInfo f  = typeof(My <>).GetField("v");
            Type      t1 = f.FieldType;

            Console.Out.WriteLine(t1);

            f = typeof(My <>).GetField("n");
            Type t2 = f.FieldType;

            Console.Out.WriteLine(t2);

            ClassDescriptor cd;

            s.EntriesByClassSimpleName.TryGetValue("My", out cd);

            FieldDescriptor fd = cd.GetFieldDescriptorByFieldName("v");

            //Search
            SimplTypesScope scope = SimplTypesScope.Get("test-basic-generics", typeof(SearchResult), typeof(Search <>), typeof(SocialSearchResult), typeof(SocialSearch));

            ClassDescriptor cdSearch;

            scope.EntriesByClassSimpleName.TryGetValue("Search", out cdSearch);

            List <GenericTypeVar> classGenericTypeVars = cdSearch.GetGenericTypeVars();

            foreach (GenericTypeVar genericTypeVar in classGenericTypeVars)
            {
                Console.Out.WriteLine(genericTypeVar.ToString());
            }

            FieldDescriptor       fdSearchResults      = cdSearch.GetFieldDescriptorByFieldName("searchResults");
            List <GenericTypeVar> fieldGenericTypeVars = fdSearchResults.GetGenericTypeVars();

            foreach (GenericTypeVar genericTypeVar in fieldGenericTypeVars)
            {
                Console.Out.WriteLine(genericTypeVar.ToString());
            }

            scope.EntriesByClassSimpleName.TryGetValue("SocialSearch", out cdSearch);
            classGenericTypeVars = cdSearch.GetGenericTypeVars();
            foreach (GenericTypeVar genericTypeVar in classGenericTypeVars)
            {
                Console.Out.WriteLine(genericTypeVar.ToString());
            }

            fdSearchResults      = cdSearch.GetFieldDescriptorByFieldName("searchResults");
            fieldGenericTypeVars = fdSearchResults.GetGenericTypeVars();
            foreach (GenericTypeVar genericTypeVar in fieldGenericTypeVars)
            {
                Console.Out.WriteLine(genericTypeVar.ToString());
            }

            SimplTypesScope.DisableGraphSerialization();
        }