當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。