本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例9: BaseClassPropertyReturnsClassAddedUsingAddBaseClassMethod
public void BaseClassPropertyReturnsClassAddedUsingAddBaseClassMethod()
{
MockClass c = new MockClass();
MockClass baseClass = new MockClass();
c.AddBaseClass(baseClass);
Assert.AreEqual(baseClass, c.BaseClass);
}