Пример #1
0
        public void ClassMapperTest()
        {
            const string superClass    = "superClass";
            var          elementFinder = new FakeClassElementFinder(NewClassName, new[] { superClass });
            var          mapper        = new ClassMapper(elementFinder);

            var mappedClass       = mapper.GetMappedItem();
            var mappedName        = mappedClass.Name;
            var mappedSupperClass = mappedClass.SuperClasses.FirstOrDefault();

            Assert.AreEqual(NewClassName, mappedName);
            Assert.AreEqual(superClass, mappedSupperClass);
        }
Пример #2
0
        public void TestClass_StaticFieldsMap()
        {
            const string staticFieldId   = "newStaticFieldId";
            var          assignStatement = BuildAssignment(new[] { staticFieldId });
            var          elementFinder   = new FakeClassElementFinder(NewClassName, new[] { assignStatement });
            var          mapper          = new ClassMapper(elementFinder);

            var mappedClass     = mapper.GetMappedItem();
            var mappedField     = mappedClass.Fields.FirstOrDefault();
            var mappedFieldName = mappedField.Identifier.GetField();

            Assert.AreEqual(staticFieldId, mappedFieldName);
            Assert.IsTrue(mappedField.IsStatic);
        }
Пример #3
0
        public void TestClass_MethodMap()
        {
            const string newMethodName   = "newMethod";
            const string instancePointer = "InstancePointer";

            var methodElementsFinder = new FakeInstanceMethodElementFinder(newMethodName, new[] { instancePointer });
            var elementFinder        = new FakeClassElementFinder(NewClassName, new[] { methodElementsFinder });

            var mapper            = new ClassMapper(elementFinder);
            var mappedClass       = mapper.GetMappedItem();
            var mappedMethods     = mappedClass.Methods.FirstOrDefault();
            var mappedMethodsName = mappedMethods.Name;

            Assert.AreEqual(newMethodName, mappedMethodsName);
        }
Пример #4
0
        public void TestClass_InstanceFieldsMap()
        {
            const string instanceFieldId = "newInstanceFieldId";

            var constructor   = BuildConstructor(instanceFieldId);
            var elementFinder = new FakeClassElementFinder(NewClassName, constructor);
            var mapper        = new ClassMapper(elementFinder);

            var mappedClass     = mapper.GetMappedItem();
            var mappedField     = mappedClass.Fields.FirstOrDefault();
            var mappedFieldName = mappedField.Identifier.GetField();

            Assert.AreEqual(instanceFieldId, mappedFieldName);
            Assert.IsFalse(mappedField.IsStatic);
        }