当前位置: 首页>>代码示例>>C#>>正文


C# MockClass.AddBaseClass方法代码示例

本文整理汇总了C#中UnitTesting.Tests.Utils.MockClass.AddBaseClass方法的典型用法代码示例。如果您正苦于以下问题:C# MockClass.AddBaseClass方法的具体用法?C# MockClass.AddBaseClass怎么用?C# MockClass.AddBaseClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnitTesting.Tests.Utils.MockClass的用法示例。


在下文中一共展示了MockClass.AddBaseClass方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetUp

		public void SetUp()
		{
			MockProjectContent projectContent = new MockProjectContent();
			
			// Create the base test class.
			MockClass baseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.ReflectionOrCecilLayerTests");
			MockMethod baseMethod = new MockMethod(baseClass, "InheritanceTests");
			baseMethod.Attributes.Add(new MockAttribute("Test"));
			baseClass.Methods.Add(baseMethod);
			
			// Add a second method that does not have a Test attribute.
			baseMethod = new MockMethod(baseClass, "NonTestMethod");
			baseClass.Methods.Add(baseMethod);
			
			// Create the derived test class.
			c = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.CecilLayerTests");
			c.SetDotNetName(c.FullyQualifiedName);
			c.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(c);

			// Set derived class's base class.
			c.AddBaseClass(baseClass);
			
			// Create TestClass.
			MockTestFrameworksWithNUnitFrameworkSupport testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			testClass = new TestClass(c, testFrameworks);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:27,代码来源:AbstractBaseClassWithTestMethodsTestFixture.cs

示例2: Init

		public void Init()
		{
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			
			// Add a test class.
			MockProjectContent projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture");
			c.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(c);
			
			// Add first method.
			var method = new MockMethod(c, "MyTest");
			method.Attributes.Add(new MockAttribute("Test"));
			c.Methods.Add(method);
			
			// Add duplicate method.
			c.Methods.Add(method);
			
			// Add a base class that has duplicate methods.
			MockClass baseClass = new MockClass(projectContent, "RootNamespace.MyTestFixtureBase");
			baseClass.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(baseClass);
			c.AddBaseClass(baseClass);
			var baseClassMethod = new MockMethod(baseClass, "MyTest");
			baseClassMethod.Attributes.Add(new MockAttribute("Test"));
			baseClass.Methods.Add(baseClassMethod);
			baseClass.Methods.Add(baseClassMethod);
			
			// Create test class.
			testClass = new TestClass(c, testFrameworks);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:32,代码来源:DuplicateMethodNameTestFixture.cs

示例3: SetUp

		public void SetUp()
		{
			MockProjectContent projectContent = new MockProjectContent();
			
			// Create the base test class.
			MockClass baseClass = new MockClass(projectContent, "RootNamespace.TestFixtureBase");
			baseClass.Attributes.Add(new MockAttribute("TestFixture"));
			MockMethod baseMethod = new MockMethod(baseClass, "BaseMethod");
			baseMethod.Attributes.Add(new MockAttribute("Test"));
			baseClass.Methods.Add(baseMethod);
			
			// Create the derived test class.
			c = new MockClass(projectContent, "RootNamespace.MyTestFixture");
			c.Attributes.Add(new MockAttribute("TestFixture"));
			MockMethod method = new MockMethod(c, "DerivedMethod");
			method.Attributes.Add(new MockAttribute("Test"));
			c.Methods.Add(method);
			projectContent.Classes.Add(c);

			// Set derived class's base class.
			c.AddBaseClass(baseClass);
			
			// Create TestClass.
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			testClass = new TestClass(c, testFrameworks);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:26,代码来源:TestMethodsInBaseClassTestFixture.cs

示例4: SetUp

		public void SetUp()
		{
			MockProjectContent projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			
			// Create the top base test class.
			MockClass baseBaseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.BaseBaseTestFixture");
			MockMethod baseMethod = new MockMethod(baseBaseClass, "BaseBaseTest");
			baseMethod.Attributes.Add(new MockAttribute("Test"));
			baseBaseClass.Methods.Add(baseMethod);
			
			// Create the next level test class.
			MockClass baseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.BaseTestFixture");
			baseMethod = new MockMethod(baseClass, "BaseTest");
			baseMethod.Attributes.Add(new MockAttribute("Test"));
			baseClass.Methods.Add(baseMethod);
			
			// Create the derived test class.
			c = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.MainTestFixture");
			c.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(c);

			// Set the base class for each class in the hierarchy.
			c.AddBaseClass(baseClass);
			baseClass.AddBaseClass(baseBaseClass);
			
			// Create TestClass.
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			testClass = new TestClass(c, testFrameworks);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:30,代码来源:TwoBaseClassesWithTestMethodsTestFixture.cs

示例5: SetUp

		public void SetUp() {
			base.InitBase();
			
			baseClass = new MockClass(projectContent, "MyTests.BaseClass");
			testMethodInBaseClass = new MockMethod(baseClass, "BaseFoo");
			testMethodInBaseClass.Attributes.Add(new MockAttribute("Test"));
			baseClass.Methods.Add(testMethodInBaseClass);

			//Add TestFixture attribute to outer class
			outerClass.Attributes.Add(new MockAttribute("TestFixture"));

			//Add inner class nested in test class
			classNestedInInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest.InnerTestLevel2", "MyTests.A+InnerATest+InnerTestLevel2", innerClass);
			innerClass.InnerClasses.Add(classNestedInInnerClass);
			classNestedInInnerClass.AddBaseClass(baseClass);
			
			testProject = new TestProject(null, projectContent, testFrameworks);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:18,代码来源:DoubleNestedTestClassWithBaseType.cs

示例6: Init

		public void Init()
		{
			mockTestClass = MockClass.CreateMockClassWithoutAnyAttributes();
			mockTestClass.FullyQualifiedName = "DerivedClass";
			testMethod = new MockMethod(mockTestClass, "myTestMethod");
			mockTestClass.Methods.Add(testMethod);

			mockBaseTestClass = MockClass.CreateMockClassWithoutAnyAttributes();
			mockBaseTestClass.FullyQualifiedName = "BaseClass";
			mockBaseTestClass.Methods.Add(baseClassTestMethod);
			baseClassTestMethod = new MockMethod(mockBaseTestClass, "myBaseTestMethod");
			
			testFrameworks = new MockRegisteredTestFrameworks();
			testFrameworks.AddTestMember(testMethod);
			testFrameworks.AddTestMember(baseClassTestMethod);

			mockTestClass.AddBaseClass(mockBaseTestClass);
			
			testClass = new TestClass(mockTestClass, testFrameworks);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:20,代码来源:TestClassIsTestMethodUsesTestFrameworksTestFixture.cs

示例7: SetUp

		public void SetUp()
		{
			MockProjectContent projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			
			// Create the base test class.
			MockClass baseClass = new MockClass(projectContent, "ICSharpCode.Tests.BaseClass");
			
			// Add a virtual method to base class.
			MockMethod baseMethod = new MockMethod(baseClass, "VirtualTestMethod");
			baseMethod.Attributes.Add(new MockAttribute("Test"));
			baseMethod.Modifiers = ModifierEnum.Virtual;
			baseClass.Methods.Add(baseMethod);
			
			// Add a second method that is virtual but will not be overriden.
			baseMethod = new MockMethod(baseClass, "VirtualNonOverriddenTestMethod");
			baseMethod.Attributes.Add(new MockAttribute("Test"));
			baseMethod.Modifiers = ModifierEnum.Virtual;
			baseClass.Methods.Add(baseMethod);
			
			// Create the derived test class.
			c = new MockClass(projectContent, "ICSharpCode.Tests.DerivedClass");
			c.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(c);
			
			// Create a new test method that overrides one of the base class methods.		
			MockMethod method = new MockMethod(c, "VirtualTestMethod");
			method.Attributes.Add(new MockAttribute("Test"));
			method.Modifiers = ModifierEnum.Override;
			c.Methods.Add(method);
			
			// Set derived class's base class.
			c.AddBaseClass(baseClass);
			
			// Create TestClass.
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			testClass = new TestClass(c, testFrameworks);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:38,代码来源:OverriddenBaseTestMethodTestFixture.cs

示例8: BaseClass_AddBaseClassMethodCalled_ReturnsClassAddedUsingAddBaseClassMethod

		public void BaseClass_AddBaseClassMethodCalled_ReturnsClassAddedUsingAddBaseClassMethod()
		{
			MockClass c = new MockClass();
			MockClass baseClass = new MockClass();
			c.AddBaseClass(baseClass);
			IClass actualBaseClass = c.BaseClass;
			Assert.AreEqual(baseClass, actualBaseClass);
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:8,代码来源:MockClassTests.cs

示例9: BaseClassPropertyReturnsClassAddedUsingAddBaseClassMethod

		public void BaseClassPropertyReturnsClassAddedUsingAddBaseClassMethod()
		{
			MockClass c = new MockClass();
			MockClass baseClass = new MockClass();
			c.AddBaseClass(baseClass);
			Assert.AreEqual(baseClass, c.BaseClass);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:MockClassTestFixture.cs


注:本文中的UnitTesting.Tests.Utils.MockClass.AddBaseClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。