public void ShiftLeftTest()
        {
            // given: BitShiftProcessor
            byte[]            bytes = new byte[] { 0, 1, 2, 3, 4 };
            BitShiftProcessor proc  = new BitShiftProcessor(new EveryNthByteIndexProvider(new ByteRange(0, (uint)bytes.Length), 1), new FixedByteProvider(1), ShiftDirection.Left);

            // when: executing the processor
            var actual = proc.Apply(bytes);

            // then: correctly modified
            byte[] expected = new byte[] { 0, 2, 4, 6, 8 };
            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void MultipleProcessorTest()
        {
            // given: glitcher configuration with multiple processors
            byte[] bytes = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            GlitcherConfiguration config            = new GlitcherConfiguration();
            BitShiftProcessor     bitShiftProcessor = new BitShiftProcessor(new EveryNthByteIndexProvider(new ByteRange(0, 5), 1), new FixedByteProvider(1), ShiftDirection.Left);
            MathProcessor         mathProcessor     = new MathProcessor(new EveryNthByteIndexProvider(new ByteRange(0, (uint)bytes.Length), 1), new FixedByteProvider(1), Operation.Add, false);

            config.ProcessorChain.Add(bitShiftProcessor);
            config.ProcessorChain.Add(mathProcessor);

            // when: glitching
            byte[] actual = Glitcher.GlitchBytes(bytes, config);

            // then: bytes are correct
            byte[] expected = new byte[] { 1, 3, 5, 7, 9, 6, 7, 8, 9, 10 };
            CollectionAssert.AreEqual(expected, actual);
        }