c# - Unit test not using derived object -


I am trying to test a function that implements a number of tables, I have taken a formula, and I am currently writing a set of test cases to check the normal operation, and then to exclude two logic matters from the boundary outcomes.

The function is being tested

  public static int getNumberOfStars (Dice ourDice, int mod = 0) {int roll = ourDice.gurpsRoll () + mod; Int numerator = (int) (Math Floor ((roll-0.0) / 5.0); // Fix some possible logic bug if (numStars & lt; 1) numStars = 1; Else if (numStars> 3) numStars = 3; Return numbers; }  

Dice is something that acts as an interface with a PRGG. The work in the question roll is 3d 6 counterfeit object:

  public class counterfeit drugs: dice {public ant die roll; Public New Intimate Gurgaon Roll () {Return Dasura Roll; } ...}  

And finally, the case of the trial

  [TestMethod] Public Zero VerifyMaxNumberOfStars () {FakeDice ourDice = new FakeDice (); OurDice.diceRoll = 18; Int numDice = StarReference.getNumberOfStars (ourDice, 3); Assurance Recival (3, number); }  

The results change between run, I am leading to believe that it is not using the new function, and instead the base one (this trial never runs , But the code is running manually, showing that it gives a valid result.)

What am I doing?

This is because the new methods do not override their bases.

New methods are called only when you are using polymorphism, instead the base method will be named

Here one Example:

  fake fake = new FakeDice (); fake.gurpsRoll (); // execution of Call Identity Dice Pice = Fake; dice.gurpsRoll (); // Call Dice implementation  

for you It needs to be virtualized and then override it.

See:


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -