• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Utils.MockClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



MockClass类属于UnitTesting.Tests.Utils命名空间,在下文中一共展示了MockClass类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: ClassCreatedWithExpectedDotNetName

		public void ClassCreatedWithExpectedDotNetName()
		{
			string fullyQualifiedName = "MyNamespace.MyClass.InnerClass";
			string dotNetName = "MyNamespace.MyClass+InnerClass";
			MockClass c = new MockClass(fullyQualifiedName, dotNetName);
			Assert.AreEqual(dotNetName, c.DotNetName);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:MockClassTestFixture.cs


示例3: Init

		public void Init()
		{
			base.InitBase();
			
			project = new MockCSharpProject();
			MockBuildProjectBeforeTestRun buildProject = new MockBuildProjectBeforeTestRun();
			context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject);
			
			classToTest = MockClass.CreateMockClassWithoutAnyAttributes();
			classToTest.SetDotNetName("MyTestClass");
			
			treeView = new MockTestTreeView();
			treeView.SelectedProject = project;
			treeView.SelectedClass = classToTest;
			
			runTestCommand.Owner = treeView;
			
			runTestCommand.Run();
			
			buildProject.FireBuildCompleteEvent();
			
			TestResult result = new TestResult("MyTestClass");
			result.ResultType = TestResultType.Success;
			context.MockTestResultsMonitor.FireTestFinishedEvent(result);
			
			runTestCommand.CallTestsCompleted();
		}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:27,代码来源:RunTestsForClassTestFixture.cs


示例4: SetUp

		public void SetUp()
		{
			solution = new Solution();
			
			// Create a project to display in the test tree view.
			project = new MockCSharpProject(solution, "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;
			testClass1 = new MockClass(projectContent, "Project.Tests.MyTestFixture");
			testClass1.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(testClass1);
			
			testClass2 = new MockClass(projectContent, "Project.MyTestFixture");
			testClass2.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(testClass2);
						
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			dummyTreeView = new DummyParserServiceTestTreeView(testFrameworks);
			dummyTreeView.ProjectContentForProject = projectContent;
			
			// Load the projects into the test tree view.
			treeView = dummyTreeView as TestTreeView;
			solution.Folders.Add(project);
			treeView.AddSolution(solution);
			nodes = treeView.Nodes;
			rootNode = (ExtTreeNode)treeView.Nodes[0];
			
			treeView.SelectedNode = rootNode;
			testProject = treeView.SelectedTestProject;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:35,代码来源:TwoTestClassesInDifferentNamespacesTestFixture.cs


示例5: FullyQualifiedNameReturnsFullyQualifiedMethodName

		public void FullyQualifiedNameReturnsFullyQualifiedMethodName()
		{
			MockClass declaringType = new MockClass("MyNamespace.MyClass");
			MockMethod method = new MockMethod(declaringType, "MyMethod");
			string expectedName = "MyNamespace.MyClass.MyMethod";
			Assert.AreEqual(expectedName, method.FullyQualifiedName);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:MockMethodTestFixture.cs


示例6: InitBase

		protected void InitBase()
		{			
			projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			
			// Create the base test class.
			outerClass = new MockClass(projectContent, "MyTests.A");
			projectContent.Classes.Add(outerClass);
			
			// Create the inner test class.
			// Note the use of the DotNetName "MyTests.A+InnerTest".
			innerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass);
			innerClass.Attributes.Add(new MockAttribute("TestFixture"));

			MockMethod method = new MockMethod(innerClass, "FooBar");
			method.Attributes.Add(new MockAttribute("Test"));
			innerClass.Methods.Add(method);
			outerClass.InnerClasses.Add(innerClass);
			
			// Add another inner class that is not a test class.
			nonTestInnerClass = new MockClass(projectContent, "MyTests.A.InnerBClass", outerClass);
			outerClass.InnerClasses.Add(nonTestInnerClass);

			// Add another inner class with the same name as the InnerATest.
			// This makes sure duplicate classes are not added.
			MockClass duplicateInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass);
			duplicateInnerClass.Attributes.Add(new MockAttribute("TestFixture"));
			outerClass.InnerClasses.Add(duplicateInnerClass);
			
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			testProject = new TestProject(null, projectContent, testFrameworks);
			if (testProject.TestClasses.Count > 0) {
				testClass = testProject.TestClasses[0];
			}
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:35,代码来源:InnerClassTestFixtureBase.cs


示例7: Init

		public void Init()
		{
			IProject project = new MockCSharpProject();
			project.Name = "TestProject";
			ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);
			nunitFrameworkReferenceItem.Include = "NUnit.Framework";
			ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);

			MockProjectContent projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			
			mockClass = new MockClass(projectContent, "RootNamespace.Tests.MyTestFixture");
			mockClass.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(mockClass);
			
			// Add a method to the test class
			MockMethod mockMethod = new MockMethod(mockClass, "TestMethod1");
			mockMethod.Attributes.Add(new MockAttribute("Test"));
			mockClass.Methods.Add(mockMethod);
			
			mockMethod = new MockMethod(mockClass, "TestMethod2");
			mockMethod.Attributes.Add(new MockAttribute("Test"));
			mockClass.Methods.Add(mockMethod);
			
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			testProject = new TestProject(project, projectContent, testFrameworks);
			testClass = testProject.TestClasses[0];
			testMethod1 = testClass.TestMembers[0];
			testMethod2 = testClass.TestMembers[1];
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:30,代码来源:TestClassWithTwoMethodsTestFixture.cs


示例8: 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


示例9: 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


示例10: SetUp

		public void SetUp()
		{			
			MockProjectContent projectContent = new MockProjectContent();
			projectContent.Language = LanguageProperties.None;
			
			// Create the base test class.
			MockClass baseClass = new MockClass("ICSharpCode.SharpDevelop.Tests.ReflectionOrCecilLayerTests");
			baseClass.ProjectContent = projectContent;
			MockMethod baseMethod = new MockMethod("InheritanceTests");
			baseMethod.Attributes.Add(new MockAttribute("Test"));
			baseMethod.DeclaringType = baseClass;
			baseClass.Methods.Add(baseMethod);

			// Add a second method that does not have a Test attribute.
			baseMethod = new MockMethod("NonTestMethod");
			baseMethod.DeclaringType = baseClass;
			baseClass.Methods.Add(baseMethod);
			
			// Create the derived test class.
			c = new MockClass("ICSharpCode.SharpDevelop.Tests.CecilLayerTests");
			c.Attributes.Add(new MockAttribute("TestFixture"));
			c.ProjectContent = projectContent;
			projectContent.Classes.Add(c);

			// Set derived class's base class.
			c.BaseClass = baseClass;
			
			// Create TestClass.
			testClass = new TestClass(c);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:30,代码来源:AbstractBaseClassWithTestMethodsTestFixture.cs


示例11: DotNetName_NewInstanceCreatedWithFullyQualifiedName_ReturnsDotNetNameThatMatchesFullyQualifiedName

		public void DotNetName_NewInstanceCreatedWithFullyQualifiedName_ReturnsDotNetNameThatMatchesFullyQualifiedName()
		{
			string fullyQualifiedName = "MyNamespace.MyClass";
			MockClass c = new MockClass(fullyQualifiedName);
			string dotNetName = c.DotNetName;
			Assert.AreEqual(fullyQualifiedName, dotNetName);
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:7,代码来源:MockClassTests.cs


示例12: FullyQualifiedName_NewInstanceCreatedWithFullyQualifiedName_ReturnsFullyQualifiedName

		public void FullyQualifiedName_NewInstanceCreatedWithFullyQualifiedName_ReturnsFullyQualifiedName()
		{
			string expectedFullyQualifiedName = "MyNamespace.MyClass";
			MockClass c = new MockClass(expectedFullyQualifiedName);
			string fullyQualifiedName = c.FullyQualifiedName;
			Assert.AreEqual(expectedFullyQualifiedName, fullyQualifiedName);
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:7,代码来源:MockClassTests.cs


示例13: 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;
			projectContent.Classes.Add(c);
			
			// Add a second class with the same name.
			MockClass secondTestClass = new MockClass("RootNamespace.MyTestFixture");
			secondTestClass.ProjectContent = projectContent;
			secondTestClass.Attributes.Add(new MockAttribute("TestFixture"));
			projectContent.Classes.Add(secondTestClass);
			
			testProject = new TestProject(project, projectContent);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:25,代码来源:DuplicateClassNameTestFixture.cs


示例14: ClassCreatedWithNoNamespaceInFullyQualifiedNameHasNamespaceOfEmptyString

		public void ClassCreatedWithNoNamespaceInFullyQualifiedNameHasNamespaceOfEmptyString()
		{
			string fullyQualifiedName = "MyClass";
			MockClass c = new MockClass(fullyQualifiedName);
			string expectedNamespace = String.Empty;
			Assert.AreEqual(expectedNamespace, c.Namespace);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:MockClassTestFixture.cs


示例15: ClassCreatedWithNameTakenFromFullyQualifiedName

		public void ClassCreatedWithNameTakenFromFullyQualifiedName()
		{
			string fullyQualifiedName = "MyNamespace.MySubNamespace.MyClass";
			MockClass c = new MockClass(fullyQualifiedName);
			string expectedName = "MyClass";
			Assert.AreEqual(expectedName, c.Name);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:MockClassTestFixture.cs


示例16: 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(projectContent, "MyTests.A");
			projectContent.Classes.Add(newOuterClass);
			newUnit.Classes.Add(newOuterClass);
			
			// Create the inner test class.
			MockClass newInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", outerClass);
			newInnerClass.SetDotNetName("MyTests.A+InnerATest");
			newInnerClass.Attributes.Add(new MockAttribute("TestFixture"));
			newOuterClass.InnerClasses.Add(newInnerClass);
			
			MockMethod method = new MockMethod(newInnerClass, "FooBarRenamed");
			method.Attributes.Add(new MockAttribute("Test"));
			newInnerClass.Methods.Add(method);
			outerClass.InnerClasses.Add(newInnerClass);
			
			MockClass innerClassInInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest.InnerInnerTest", innerClass);
			innerClassInInnerClass.SetDotNetName("MyTests.A+InnerATest+InnerInnerTest");
			innerClassInInnerClass.Attributes.Add(new MockAttribute("TestFixture"));
			newInnerClass.InnerClasses.Add(innerClassInInnerClass);
		
			// Update TestProject's parse info.
			testProject.UpdateParseInfo(oldUnit, newUnit);
			
			innerTestClass = testProject.TestClasses["MyTests.A+InnerATest"];
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:34,代码来源:InnerClassMethodRenamedTestFixture.cs


示例17: GetExpressionResult

		protected override ExpressionResult GetExpressionResult()
		{
			MockClass textBoxClass = new MockClass(projectContent, "System.Windows.Forms.TextBox");
			projectContent.SetClassToReturnFromGetClass("System.Windows.Forms.TextBox", textBoxClass);
			
			return new ExpressionResult("MyTextBox", ExpressionContext.Default);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTests.cs


示例18: TwoParentNamespaces

		public void TwoParentNamespaces()
		{
			MockClass mockClass = new MockClass("TestRootNamespace.Tests.MyFixture");
			mockClass.Namespace = "TestRootNamespace.Tests";
			TestClass testClass = new TestClass(mockClass);
			Assert.AreEqual("TestRootNamespace", testClass.RootNamespace);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:ClassRootNamespaceTests.cs


示例19: 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


示例20: NoNamespace

		public void NoNamespace()
		{
			MockClass mockClass = new MockClass("MyFixture");
			mockClass.Namespace = String.Empty;
			TestClass testClass = new TestClass(mockClass);
			Assert.AreEqual(String.Empty, testClass.RootNamespace);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:ClassRootNamespaceTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SchedulerTests.UnitTestSchedulingContext类代码示例发布时间:2022-05-26
下一篇:
C# Utils.MockCSharpProject类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap