Example #1
0
        IMember GetMember(ITestTreeView treeView)
        {
            IMember member = treeView.SelectedMethod;

            if (member != null)
            {
                BaseTestMethod baseTestMethod = member as BaseTestMethod;
                if (baseTestMethod != null)
                {
                    return(baseTestMethod.Method);
                }
            }
            return(member);
        }
		public void SetUpFixture()
		{
			mockClass = new MockClass("Tests.MyTestFixture");
			mockMethod = new MockMethod(mockClass, "MyMethod");
			
			mockMethodRegion = new DomRegion(0, 0, 0, 10);
			mockMethod.Region = mockMethodRegion;
			mockMethodBodyRegion = new DomRegion(1, 0, 2, 5);
			mockMethod.BodyRegion = mockMethodBodyRegion;
			mockMethod.Modifiers = ModifierEnum.Public;
		
			MockClass returnTypeClass = new MockClass("Tests.ReturnType");
			returnType = new DefaultReturnType(returnTypeClass);
			mockMethod.ReturnType = returnType;
			
			baseTestMethod = new BaseTestMethod(mockClass, mockMethod);
		}
Example #3
0
        /// <summary>
        /// Gets the test methods for the specified class.
        /// </summary>
        TestMethodCollection GetTestMethods(IClass c)
        {
            TestMethodCollection testMethods = new TestMethodCollection();

            foreach (IMethod method in c.Methods)
            {
                if (IsTestMethod(method))
                {
                    if (!testMethods.Contains(method.Name))
                    {
                        testMethods.Add(new TestMethod(method));
                    }
                }
            }

            // Add base class test methods.
            IClass declaringType = c;

            while (c.BaseClass != null)
            {
                foreach (IMethod method in c.BaseClass.Methods)
                {
                    if (IsTestMethod(method))
                    {
                        BaseTestMethod baseTestMethod = new BaseTestMethod(declaringType, method);
                        TestMethod     testMethod     = new TestMethod(c.BaseClass.Name, baseTestMethod);
                        if (method.IsVirtual)
                        {
                            if (!testMethods.Contains(method.Name))
                            {
                                testMethods.Add(testMethod);
                            }
                        }
                        else
                        {
                            if (!testMethods.Contains(testMethod.Name))
                            {
                                testMethods.Add(testMethod);
                            }
                        }
                    }
                }
                c = c.BaseClass;
            }
            return(testMethods);
        }
		public void Init()
		{
			baseClassMethod = MockMethod.CreateMockMethodWithoutAnyAttributes();
			baseClassMethod.DeclaringType.CompilationUnit.FileName = @"c:\projects\mytest.cs";
			
			MockClass derivedClass = MockClass.CreateMockClassWithoutAnyAttributes();
			derivedClass.CompilationUnit.FileName = @"d:\projects\myderivedtestclass.cs";
			
			int methodBeginLine = 3; // 1 based.
			int methodBeginColumn = 6; // 1 based.
			baseClassMethod.Region = new DomRegion(methodBeginLine, methodBeginColumn);
			
			BaseTestMethod baseTestMethod = new BaseTestMethod(derivedClass, baseClassMethod);
			
			treeView = new MockTestTreeView();
			treeView.SelectedMethod = baseTestMethod;
			fileService = new MockFileService();
			gotoDefinitionCommand = new GotoDefinitionCommand(fileService);
			gotoDefinitionCommand.Owner = treeView;
			gotoDefinitionCommand.Run();
		}
        public override void Run()
        {
            ITestTreeView treeView = Owner as ITestTreeView;

            if (treeView != null)
            {
                IMember member = treeView.SelectedMethod;
                IClass  c      = treeView.SelectedClass;
                if (member != null)
                {
                    BaseTestMethod baseTestMethod = member as BaseTestMethod;
                    if (baseTestMethod != null)
                    {
                        member = baseTestMethod.Method;
                    }
                    GotoMember(member);
                }
                else if (c != null)
                {
                    GotoClass(c);
                }
            }
        }
Example #6
0
		/// <summary>
		/// Gets the test methods for the specified class.
		/// </summary>
		static TestMethodCollection GetTestMethods(IClass c)
		{
			TestMethodCollection testMethods = new TestMethodCollection();
			foreach (IMethod method in c.Methods) {
				if (TestMethod.IsTestMethod(method)) {
					if (!testMethods.Contains(method.Name)) {
						testMethods.Add(new TestMethod(method));
					}
				}
			}
			
			// Add base class test methods.
			IClass declaringType = c;
			while (c.BaseClass != null) {
				foreach (IMethod method in c.BaseClass.Methods) {
					if (TestMethod.IsTestMethod(method)) {
						BaseTestMethod baseTestMethod = new BaseTestMethod(declaringType, method);
						TestMethod testMethod = new TestMethod(c.BaseClass.Name, baseTestMethod);
						if (method.IsVirtual) {
							if (!testMethods.Contains(method.Name)) {
								testMethods.Add(testMethod);	
							}
						} else {
							if (!testMethods.Contains(testMethod.Name)) {
								testMethods.Add(testMethod);
							}
						}
					}
				}
				c = c.BaseClass;
			}
			return testMethods;
		}