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


C# Utils.MockClass类代码示例

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


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


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