Beispiel #1
0
		public static MockMethod CreateMockMethodWithAttribute(MockAttribute attribute)
		{
			List<MockAttribute> attributes = new List<MockAttribute>();
			attributes.Add(attribute);
			
			return CreateMockMethodWithAttributes(attributes);
		}
Beispiel #2
0
        public static MockClass CreateMockClassWithAttribute(MockAttribute attribute)
        {
            List <MockAttribute> attributes = new List <MockAttribute>();

            attributes.Add(attribute);

            return(CreateMockClassWithAttributes(attributes));
        }
		public void IsTestMethodReturnsTrueWhenProjectIsNull()
		{
			MockAttribute testAttribute = new MockAttribute("Test");
			MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
			MockProjectContent mockProjectContent = (MockProjectContent)mockMethod.DeclaringType.ProjectContent;
			mockProjectContent.Project = null;

			Assert.IsTrue(testFramework.IsTestMethod(mockMethod));
		}
		public void IsTestMember_MethodHasFullyQualifiedNUnitTestAttribute_ReturnsTrue()
		{
			CreateTestFramework();
			MockAttribute testAttribute = new MockAttribute("NUnit.Framework.TestAttribute");
			MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
			
			bool result = testFramework.IsTestMember(mockMethod);
			
			Assert.IsTrue(result);
		}
		public void IsTestMember_MethodHasTestAttributeWithoutAttributePart_ReturnsTrue()
		{
			CreateTestFramework();
			MockAttribute testAttribute = new MockAttribute("Test");
			MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
			
			bool result = testFramework.IsTestMember(mockMethod);
			
			Assert.IsTrue(result);
		}
		public void Init()
		{
			MockAttribute testAttribute = new MockAttribute("Test");
			methodWithTestAttribute = MockMethod.CreateMockMethodWithAttribute(testAttribute);
			memberNodeForMethodWithTestAttribute = new MockMemberNode(methodWithTestAttribute);
			
			testFrameworks = new MockRegisteredTestFrameworks();
			testFrameworks.AddTestMethod(methodWithTestAttribute);
			
			testableCondition = new TestableCondition(testFrameworks);
		}
		public void Init()
		{
			MockAttribute testAttribute = new MockAttribute("Test");
			classWithTestAttribute = MockClass.CreateMockClassWithAttribute(testAttribute);
			IProject project = classWithTestAttribute.MockProjectContent.ProjectAsIProject;
			classNodeForClassWithTestAttribute = new ClassNode(project, classWithTestAttribute);
			
			testFrameworks = new MockRegisteredTestFrameworks();
			testFrameworks.AddTestClass(classWithTestAttribute);
			
			testableCondition = new TestableCondition(testFrameworks);
		}
		public void IsTestClassReturnsTrueHasClassHasFullyQualifiedNUnitTestFixtureAttribute()
		{
			MockAttribute testFixtureAttribute = new MockAttribute("MbUnit.Framework.TestFixtureAttribute");
			MockClass mockClass = MockClass.CreateMockClassWithAttribute(testFixtureAttribute);
			Assert.IsTrue(testFramework.IsTestClass(mockClass));
		}
		public void IsTestClassReturnsTrueHasClassHasTestFixtureAttribute()
		{
			MockAttribute testFixtureAttribute = new MockAttribute("TestFixtureAttribute");
			MockClass mockClass = MockClass.CreateMockClassWithAttribute(testFixtureAttribute);
			Assert.IsTrue(testFramework.IsTestClass(mockClass));
		}
		public void IsTestMember_ProjectIsNull_ReturnsTrue()
		{
			CreateTestFramework();
			var testAttribute = new MockAttribute("Test");
			MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
			MockProjectContent mockProjectContent = (MockProjectContent)mockMethod.DeclaringType.ProjectContent;
			mockProjectContent.Project = null;
			
			bool result = testFramework.IsTestMember(mockMethod);
			
			Assert.IsTrue(result);
		}
		public void IsTestMember_FieldHasOneAttribute_ReturnsFalseAndDoesNotThrowInvalidCastException()
		{
			CreateTestFramework();
			MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes();
			var field = new DefaultField(mockClass, "MyField");
			var testAttribute = new MockAttribute("Test");
			field.Attributes.Add(testAttribute);
			
			bool result = testFramework.IsTestMember(field);
			
			Assert.IsFalse(result);
		}
		public void IsTestMember_MethodHasParameters_ReturnsFalse()
		{
			CreateTestFramework();
			var testAttribute = new MockAttribute("Test");
			MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
			var mockParameter = new MockParameter();
			mockMethod.Parameters.Add(mockParameter);
			
			bool result = testFramework.IsTestMember(mockMethod);
			
			Assert.IsFalse(result);
		}
		public void IsTestMethodReturnsTrueWhenMethodHasFullyQualifiedNUnitTestAttribute()
		{
			MockAttribute testAttribute = new MockAttribute("MbUnit.Framework.TestAttribute");
			MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
			Assert.IsTrue(testFramework.IsTestMethod(mockMethod));
		}
		public void IsTestMethodReturnsTrueWhenMethodHasTestAttributeAttribute()
		{
			MockAttribute testAttribute = new MockAttribute("TestAttribute");
			MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
			Assert.IsTrue(testFramework.IsTestMethod(mockMethod));
		}
		public void IsTestMethodReturnsFalseWhenMethodHasHasParameters()
		{
			MockAttribute testAttribute = new MockAttribute("Test");
			MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute);
			MockParameter mockParameter = new MockParameter();
			mockMethod.Parameters.Add(mockParameter);
			
			Assert.IsFalse(testFramework.IsTestMethod(mockMethod));
		}
		public void IsTestClassReturnsFalseWhenClassHasTestFixtureAttributeAndIsAbstract() {
			MockAttribute testAttribute = new MockAttribute("TestFixture");
			MockClass mockClass = MockClass.CreateMockClassWithAttribute(testAttribute);
			mockClass.Modifiers = mockClass.Modifiers | ModifierEnum.Abstract;
			Assert.IsFalse(testFramework.IsTestClass(mockClass));
		}