Exemplo n.º 1
0
        public void Test_dataModBeacon_StateFns()
        {
            // Arrange
            dataModBeacon bc = new dataModBeacon();

            int[] testArray   = new int[] { 1, 2, 3, 4, 5 };
            int[] signalArray = new int[5];
            int[] assertArray = new int[] { 1, 0, 2, 0, 3 };

            // Act
            bc.setSeq(testArray);
            for (int i = 0; i < signalArray.Length; i++)
            {
                if (i % 2 == 0)
                {
                    bc.turnOn();
                }
                else
                {
                    bc.turnOff();
                }
                signalArray[i] = bc.signal();
            }

            // Assert
            CollectionAssert.AreEqual(signalArray, assertArray);
        }
Exemplo n.º 2
0
        public void Test_dataModBeacon_ScrambleOddLengthSeq()
        {
            // Arrange
            dataModBeacon d = new dataModBeacon();

            int[] testArray = new int[7] {
                8, 24, 30, 31, 6, 11, 66
            };
            int[] assertArray = new int[7] {
                8, 24, 2, 30, 2, 6, 66
            };

            // Act
            int[] dScramble = d.scramble(testArray);

            // Assert
            CollectionAssert.AreEqual(dScramble, assertArray);
        }
Exemplo n.º 3
0
        public void Test_dataModBeacon_ScrambleLargeMode()
        {
            // Arrange
            dataModBeacon d = new dataModBeacon();

            d.setMode(true);
            int[] testArray = new int[6] {
                8, 24, 30, 31, 6, 11
            };
            int[] assertArray = new int[6] {
                24, 8, 30, 2, 6, 2
            };

            // Act
            int[] dScramble = d.scramble(testArray);

            // Assert
            CollectionAssert.AreEqual(dScramble, assertArray);
        }
Exemplo n.º 4
0
        public void Test_dataModBeacon_FilterSmallMode()
        {
            // Arrange
            dataModBeacon d = new dataModBeacon(13);

            int[] testArray = new int[6] {
                8, 24, 30, 31, 6, 11
            };
            int[] assertArray = new int[4] {
                7, 1, 5, 1
            };

            // Act
            d.scramble(testArray); // NOTE: All prime numbers will be replaced with '2' before updating
            int[] dFilter = d.filter();

            // Assert
            CollectionAssert.AreEqual(dFilter, assertArray);
        }
Exemplo n.º 5
0
        public void Test_dataModBeacon_ChargeFns()
        {
            // Arrange
            dataModBeacon bc = new dataModBeacon();

            int[] testArray   = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            int[] signalArray = new int[11];
            int[] assertArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0 };

            // Act
            bc.setSeq(testArray);
            for (int i = 0; i < signalArray.Length; i++)
            {
                signalArray[i] = bc.signal();
            }
            bc.recharge(5);

            // Assert
            Assert.AreEqual(bc.getCharge(), 5);
            CollectionAssert.AreEqual(signalArray, assertArray);
        }