Example #1
0
        public void Test_ReviveWhileActive_PermanentDeactivation_jumpPrime()
        {
            // Arrange
            int       testVal = 10000;
            jumpPrime obj;
            bool      expectedInitialIsActive = false;
            bool      expectedSecondIsActive  = false;
            bool      expectedFinalIsActive   = false;

            // Act
            obj = new jumpPrime(testVal);
            obj.revive();
            bool initialIsActive = obj.getActiveStatus();

            obj.revive();
            bool secondIsActive = obj.getActiveStatus();

            obj.reset(testVal);
            bool finalIsActive = obj.getActiveStatus();

            // Assert
            Assert.AreEqual(expectedInitialIsActive, initialIsActive);
            Assert.AreEqual(expectedSecondIsActive, secondIsActive);
            Assert.AreEqual(expectedFinalIsActive, finalIsActive);
        }
Example #2
0
        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);
        }
Example #3
0
        public void Test_Reset()
        {
            //arrange
            int       number = 2488;
            jumpPrime obj    = new jumpPrime(number);
            int       limit  = 14; //uppper prime is 2503 & max number of queries is 26
            //act
            bool expectedState = true;

            for (int i = 0; i < limit; i++)
            {
                obj.up();
            }
            obj.reset();    //num of queries should be zero
            for (int i = 0; i < limit; i++)
            {
                obj.up();
            }
            //even though we query 28 times over the bounds of 26, we reset so it should still be active
            //assert
            Assert.AreEqual(expectedState, obj.getActive());
        }