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


C# MockClass.SetCompoundClass方法代码示例

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


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

示例1: Init

		public void Init()
		{
			resultChangedCalled = false;
			classesAdded = new List<TestClass>();
			classesRemoved = new List<TestClass>();
			
			// Create a project.
			project = new MockCSharpProject();
			project.Name = "TestProject";
			ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);
			nunitFrameworkReferenceItem.Include = "NUnit.Framework";
			ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);
			
			// Add a test class with a TestFixture attributes.
			projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture");
			c.SetCompoundClass(c);
			c.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(c);
			
			// Add a second class that has no test fixture attribute.
			MockClass nonTestClass = new MockClass(projectContent);
			projectContent.Classes.Add(nonTestClass);
			
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			testProject = new TestProject(project, projectContent, testFrameworks);
			testProject.TestClasses.TestClassAdded += TestClassAdded;
			testProject.TestClasses.TestClassRemoved += TestClassRemoved;
			
			testClass = testProject.TestClasses[0];
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:32,代码来源:TestProjectWithOneClassTestFixture.cs

示例2: Init

		public void Init()
		{
			base.InitBase();

			DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent);
			oldUnit.Classes.Add(outerClass);
			
			// Create new compilation unit with inner class that has its method renamed.
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
			MockClass newOuterClass = new MockClass("MyTests.A");
			newOuterClass.ProjectContent = projectContent;
			projectContent.Classes.Add(newOuterClass);
			newOuterClass.SetCompoundClass(newOuterClass);
			newUnit.Classes.Add(newOuterClass);
			
			// Create the inner test class.
			MockClass newInnerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest");
			newInnerClass.Attributes.Add(new MockAttribute("TestFixture"));
			newInnerClass.ProjectContent = projectContent;
			newInnerClass.DeclaringType = outerClass; // Declaring type is outer class.	
			newInnerClass.SetCompoundClass(newInnerClass);
			newOuterClass.InnerClasses.Add(newInnerClass);
			
			MockMethod method = new MockMethod("FooBarRenamed");
			method.Attributes.Add(new MockAttribute("Test"));
			method.DeclaringType = newInnerClass;
			newInnerClass.Methods.Add(method);
			outerClass.InnerClasses.Add(newInnerClass);
		
			// Update TestProject's parse info.
			testProject.UpdateParseInfo(oldUnit, newUnit);
			
			innerTestClass = testProject.TestClasses["MyTests.A+InnerATest"];
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:34,代码来源:InnerClassMethodRenamedTestFixture.cs

示例3: Init

		public void Init()
		{
			base.InitBase();
			
			DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent);
			oldUnit.Classes.Add(outerClass);
			
			// Create new compilation unit with inner class that no longer has the TestFixture attribute.
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
			MockClass newOuterClass = new MockClass("MyTests.A");
			newOuterClass.ProjectContent = projectContent;
			projectContent.Classes.Add(newOuterClass);
			newOuterClass.SetCompoundClass(newOuterClass);
			newUnit.Classes.Add(newOuterClass);
			
			// Create the inner test class.
			MockClass newInnerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest");
			newInnerClass.ProjectContent = projectContent;
			newInnerClass.DeclaringType = outerClass; // Declaring type is outer class.	
			newInnerClass.SetCompoundClass(newInnerClass);
			newOuterClass.InnerClasses.Add(newInnerClass);
		
			// Update TestProject's parse info.
			testProject.UpdateParseInfo(oldUnit, newUnit);			
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:25,代码来源:InnerClassTestFixtureAttributeRemovedTestFixture.cs

示例4: TestFixtureAttributeAdded

		public void TestFixtureAttributeAdded()
		{
			// Create an old compilation unit with the test class
			// but without a [TestFixture] attribute.
			DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent);
			MockClass newClass = new MockClass("RootNamespace.MyNewTestFixture");
			newClass.ProjectContent = projectContent;
			newClass.SetCompoundClass(newClass);
			oldUnit.Classes.Add(newClass);

			// Create a new compilation unit with the test class
			// having a [TestFixture] attribute.
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
			newClass = new MockClass("RootNamespace.MyNewTestFixture");
			newClass.Attributes.Add(new MockAttribute("TestFixture"));
			newClass.ProjectContent = projectContent;
			newClass.SetCompoundClass(newClass);
			newUnit.Classes.Add(newClass);

			// Update TestProject's parse info.
			testProject.UpdateParseInfo(oldUnit, newUnit);
			
			Assert.IsTrue(testProject.TestClasses.Contains("RootNamespace.MyNewTestFixture"),
				"New class should have been added to the set of TestClasses.");
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:25,代码来源:EmptyProjectTestFixture.cs

示例5: Init

		public void Init()
		{
			base.InitBase();

			DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent);
			oldUnit.Classes.Add(outerClass);
			
			// Create new compilation unit with extra class.
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
			MockClass newOuterClass = new MockClass("MyTests.A");
			newOuterClass.ProjectContent = projectContent;
			projectContent.Classes.Add(newOuterClass);
			newOuterClass.SetCompoundClass(newOuterClass);
			newUnit.Classes.Add(newOuterClass);
			
			// Create the inner test class.
			// Note the use of the DotNetName "MyTests.A+InnerTest".
			MockClass newInnerClass = new MockClass("MyTests.A.InnerATestMod", "MyTests.A+InnerATestMod");
			newInnerClass.Attributes.Add(new MockAttribute("TestFixture"));
			newInnerClass.ProjectContent = projectContent;
			newInnerClass.DeclaringType = outerClass; // Declaring type is outer class.	
			newOuterClass.InnerClasses.Add(newInnerClass);
			
			// Update TestProject's parse info.
			testProject.UpdateParseInfo(oldUnit, newUnit);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:26,代码来源:InnerClassNameChangesTestFixture.cs

示例6: Init

		public void Init()
		{
			// Create a project to display.
			project = new MockCSharpProject();
			project.Name = "TestProject";
			ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);
			nunitFrameworkReferenceItem.Include = "NUnit.Framework";
			ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);
			
			// Add a test class.
			projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			MockClass c = new MockClass("RootNamespace.MyTestFixture");
			c.Attributes.Add(new MockAttribute("TestFixture"));
			c.ProjectContent = projectContent;
			c.SetCompoundClass(c);
			MockMethod test1Method = new MockMethod("Test1");
			test1Method .DeclaringType = c;
			test1Method .Attributes.Add(new MockAttribute("Test"));
			c.Methods.Add(test1Method);
			
			// Test 2 method is from a duplicate test class.
			MockMethod test2Method = new MockMethod("Test2"); 
			test2Method.DeclaringType = c;
			test2Method.Attributes.Add(new MockAttribute("Test"));
			c.Methods.Add(test2Method);			
			projectContent.Classes.Add(c);
						
			testProject = new TestProject(project, projectContent);
			
			// Make sure test methods are created, otherwise
			// the Test2 method will never be looked at due to lazy evaluation
			// of test method.s
			int count = testProject.TestClasses[0].TestMethods.Count;
			
			// Change the name of the second test class.
			DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent);
			oldUnit.Classes.Add(c);
			c.Methods.Remove(test2Method); // Remove duplicate test class method.

			
			// Create new compilation unit with inner class that has its method renamed.
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
			MockClass newTestClass = new MockClass("RootNamespace.MyNewTestFixture");
			newTestClass.ProjectContent = projectContent;
			newTestClass.Attributes.Add(new MockAttribute("TestFixture"));
			newTestClass.SetCompoundClass(newTestClass);
			projectContent.Classes.Add(newTestClass);
			newTestClass.Methods.Add(test2Method);
			newUnit.Classes.Add(newTestClass);

			testProject.UpdateParseInfo(oldUnit, newUnit);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:53,代码来源:DuplicateClassNameChangedTestFixture.cs

示例7: NewClassInParserInfo

		public void NewClassInParserInfo()
		{			
			// Create new compilation unit with extra class.
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
			MockClass newClass = new MockClass("RootNamespace.MyNewTestFixture");
			newClass.Attributes.Add(new MockAttribute("TestFixture"));
			newClass.ProjectContent = projectContent;
			newClass.SetCompoundClass(newClass);
			newUnit.Classes.Add(newClass);
			
			// Update TestProject's parse info.
			testProject.UpdateParseInfo(null, newUnit);
			
			Assert.IsTrue(testProject.TestClasses.Contains("RootNamespace.MyNewTestFixture"));
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:15,代码来源:EmptyProjectTestFixture.cs

示例8: NewClassInParserInfoWithoutTestFixtureAttribute

		public void NewClassInParserInfoWithoutTestFixtureAttribute()
		{
			// Create old compilation unit.
			DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent);
			MockClass mockClass = (MockClass)testClass.Class;
			mockClass.SetCompoundClass(mockClass);
			oldUnit.Classes.Add(testClass.Class);
			
			// Create new compilation unit with extra class.
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
			newUnit.Classes.Add(testClass.Class);
			MockClass newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture");
			newClass.SetCompoundClass(newClass);
			newUnit.Classes.Add(newClass);
			
			// Update TestProject's parse info.
			testProject.UpdateParseInfo(oldUnit, newUnit);
			
			Assert.IsFalse(testProject.TestClasses.Contains("RootNamespace.MyNewTestFixture"));
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:20,代码来源:TestProjectWithOneClassTestFixture.cs

示例9: TestClassInNewCompilationUnitOnly

		public void TestClassInNewCompilationUnitOnly()
		{
			// Create old compilation unit.
			projectContent.Classes.Clear();
			DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent);
			
			// Create new compilation unit with class that 
			// already exists in the project.
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
			newUnit.Classes.Add(testClass.Class);
			MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture");
			c.Attributes.Add(new MockAttribute("TestFixture"));
			c.SetCompoundClass(c);
			newUnit.Classes.Add(c);
			
			// Update TestProject's parse info.
			testProject.UpdateParseInfo(oldUnit, newUnit);
			
			Assert.IsTrue(testProject.TestClasses.Contains("RootNamespace.MyTestFixture"));
			Assert.AreEqual(0, classesAdded.Count);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:21,代码来源:TestProjectWithOneClassTestFixture.cs

示例10: GetCompoundClass_SetCompoundClassMethodCalled_ReturnsClassPassedToSetCompoundClass

		public void GetCompoundClass_SetCompoundClassMethodCalled_ReturnsClassPassedToSetCompoundClass()
		{
			MockClass c = new MockClass();
			MockClass compoundClass = new MockClass();
			c.SetCompoundClass(compoundClass);
			IClass actualCompoundClass = c.GetCompoundClass();
			Assert.AreEqual(compoundClass, actualCompoundClass);
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:8,代码来源:MockClassTests.cs

示例11: GetCompoundClassReturnsClassSetWithSetCompoundClass

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

示例12: NewClassInParserInfo

		public void NewClassInParserInfo()
		{
			// Create old compilation unit.
			DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent);
			MockClass mockClass = (MockClass)testClass.Class;
			mockClass.SetCompoundClass(mockClass);
			oldUnit.Classes.Add(testClass.Class);
			
			// Create new compilation unit with extra class.
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent);
			newUnit.Classes.Add(testClass.Class);
			MockClass newClass = new MockClass("RootNamespace.MyNewTestFixture");
			newClass.Attributes.Add(new MockAttribute("TestFixture"));
			newClass.ProjectContent = projectContent;
			newClass.SetCompoundClass(newClass);
			newUnit.Classes.Add(newClass);
			
			// Update TestProject's parse info.
			testProject.UpdateParseInfo(oldUnit, newUnit);
			
			Assert.IsTrue(testProject.TestClasses.Contains("RootNamespace.MyNewTestFixture"));
			Assert.AreEqual(1, classesAdded.Count);
			Assert.AreSame(newClass, classesAdded[0].Class);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:24,代码来源:TestProjectWithOneClassTestFixture.cs

示例13: ParserInfoUpdated

		public void ParserInfoUpdated()
		{
			DefaultCompilationUnit newUnit = new DefaultCompilationUnit(pad.ProjectContent);
			MockClass mockClass = new MockClass("MyTestFixture");
			mockClass.Attributes.Add(new MockAttribute("TestFixture"));
			mockClass.ProjectContent = pad.ProjectContent;
			mockClass.SetCompoundClass(mockClass);
			newUnit.Classes.Add(mockClass);

			ExtTreeNode rootNode = (ExtTreeNode)pad.TestTreeView.Nodes[0];
			rootNode.Expanding();

			pad.CallUpdateParseInfo(null, newUnit);
			
			Assert.AreEqual(1, rootNode.Nodes.Count);
			Assert.AreEqual("MyTestFixture", rootNode.Nodes[0].Text);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:17,代码来源:SolutionOpenedTestFixture.cs


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