Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Adder
- {
- public virtual int Add(int operand1, int operand2)
- {
- return operand1 + operand2;
- }
- }
- public class AdvancedAdder : Adder
- {
- }
- public abstract class AdderUnitTestsBase
- {
- protected static Adder Adder;
- [DataTestMethod]
- [DataRow(2, 2, 4)]
- [DataRow(-1, 2, 1)]
- [DataRow(2, -3, -1)]
- [DataRow(0, 0, 0)]
- public void Add_ReturnsCorrectResult(
- int operand1, int operand2, int result)
- {
- Assert.AreEqual(result, Adder.Add(operand1, operand2));
- }
- }
- [TestClass]
- public class AdderUnitTests : AdderUnitTestsBase
- {
- [ClassInitialize]
- public static void ClassInit(TestContext context)
- {
- Adder = new Adder();
- }
- }
- [TestClass]
- public class AdvancedAdderUnitTests : AdderUnitTestsBase
- {
- [ClassInitialize]
- public static void ClassInit(TestContext context)
- {
- Adder = new AdvancedAdder();
- }
- }
- public class AdvancedAdder : Adder
- {
- public int Add(int operand1, int operand2, int operand3)
- {
- return operand1 + operand2 + operand3;
- }
- public uint Add(uint operand1, uint operand2)
- {
- return operand1 + operand2;
- }
- }
- public class AdvancedAdder : Adder
- {
- public override int Add(int operand1, int operand2)
- {
- return operand1 - operand2;
- }
- }
- public void method()
- {
- switch (this.getType().Name)
- {
- case "Square":
- // do the square thing
- break;
- case "Rectangle":
- // do the rectangle thing
- break;
- }
- }
- PARENT
- ^
- |
- CHILD
Add Comment
Please, Sign In to add comment