public void Test_Reset_jumpPrime() { // Arrange int testVal = 1000; jumpPrime obj; bool expectedInitialIsActive = false; bool expectedFinalIsActive = true; int expectedOrigUpperPrime = 1009; int expectedOrigLowerPrime = 997; int expectedJumpUpperPrime = 1019; int expectedJumpLowerPrime = 1013; // Act obj = new jumpPrime(testVal); while (obj.getActiveStatus()) { obj.up(); } bool initialIsActive = obj.getActiveStatus(); int jumpUpperPrime = obj.up(); int jumpLowerPrime = obj.down(); obj.reset(testVal); // Assert Assert.AreEqual(expectedInitialIsActive, initialIsActive); Assert.AreEqual(expectedFinalIsActive, obj.getActiveStatus()); Assert.AreEqual(expectedOrigUpperPrime, obj.up()); Assert.AreEqual(expectedOrigLowerPrime, obj.down()); Assert.AreEqual(expectedJumpUpperPrime, jumpUpperPrime); Assert.AreEqual(expectedJumpLowerPrime, jumpLowerPrime); }
public void Test_ValidConstructor_jumpPrime() { jumpPrime j = new jumpPrime(1424); Assert.AreEqual(j.up(), 1427); Assert.AreEqual(j.down(), 1423); }
public void Test_InvalidConstructor_jumpPrime() { jumpPrime j = new jumpPrime(5); Assert.AreEqual(j.up(), 0); Assert.AreEqual(j.down(), 0); }
public void Test_Down() { //arrange Random random = new Random(); int number = random.Next(1000, 10000); jumpPrime obj = new jumpPrime(number); //act int expectedValue = number - 1; bool notPrime = false; while (true) { for (int i = 2; i < expectedValue / 2; i++) { if (expectedValue % i == 0) { notPrime = true; break; } } if (!notPrime) { break; } expectedValue--; notPrime = false; } //assert Assert.AreEqual(expectedValue, obj.down()); }
public void Test_Down_into_Inactive() { //arrange int number = 1000; jumpPrime obj = new jumpPrime(number); //act int expectedInt = 0; bool expectedState = false; //assert Assert.AreEqual(expectedInt, obj.down()); Assert.AreEqual(expectedState, obj.getActive()); }
public void Test_LowerPrime_jumpPrime() { // Arrange int testVal = 2020; jumpPrime obj; int expectedLowerPrime = 2017; // Act obj = new jumpPrime(testVal); int lowerPrime = obj.down(); // Assert Assert.AreEqual(expectedLowerPrime, lowerPrime); }
public void Test_Revive_jumpPrime() { // Arrange int testVal = 4002; jumpPrime obj; bool expectedInitialIsActive = false; bool expectedFinalIsActive = true; int originalLowerPrime = 4001; // Act obj = new jumpPrime(testVal); while (obj.getActiveStatus()) { obj.down(); } bool initialIsActive = obj.getActiveStatus(); obj.revive(); // Assert Assert.AreEqual(expectedInitialIsActive, initialIsActive); Assert.AreEqual(expectedFinalIsActive, obj.getActiveStatus()); Assert.AreNotEqual(originalLowerPrime, obj.down()); }
public void Test_Primes_InputLessThat1000_jumpPrime() { // Arange int testVal = 50; jumpPrime obj; int expectedUpperPrime = 1009; int expectedLowerPrime = 997; // Act obj = new jumpPrime(testVal); int upperPrime = obj.up(); int lowerPrime = obj.down(); // Assert Assert.AreEqual(expectedUpperPrime, upperPrime); Assert.AreEqual(expectedLowerPrime, lowerPrime); }