Exemple #1
0
        public void Logical_PostMutation_AndToXor02()
        {
            // Arrange
            var binary   = DllTestHelper.CompileTestBinary(folder);
            var expected = true;

            // Act
            var mutatedBinary = DllTestHelper.MutateMethod <BitwiseMutationAnalyzer>(binary, "AndOperator", OpCodes.Xor);

            using (var binaryInteractor = new DllTestHelper(mutatedBinary))
            {
                var  instance = binaryInteractor.CreateInstance(nameSpace);
                bool actual   = instance.AndOperator(true, false);

                // Assert
                Assert.AreEqual(expected, actual);
            }
        }
Exemple #2
0
        public void Bitwise_PostMutation(string methodName, object argument1, object argument2,
                                         string expectedOpCodeName, uint expected)
        {
            // Arrange
            var binary         = DllTestHelper.CompileTestBinary(_folder);
            var opCodeExpected = expectedOpCodeName.ParseOpCode();

            // Act
            var mutatedBinary =
                DllTestHelper.MutateMethod <BitwiseMutationAnalyzer>(binary, methodName, opCodeExpected);

            using (var binaryInteractor = new DllTestHelper(mutatedBinary))
            {
                var actual = (uint)binaryInteractor.DynamicMethodCall(_nameSpace, methodName.FirstCharToUpper(),
                                                                      new[] { argument1, argument2 });

                // Assert
                Assert.AreEqual(expected, actual);
            }
        }
Exemple #3
0
        public void BooleanBranch_PostMutation(string methodName, string expectedOpCodeName, object argument1,
                                               bool simplify)
        {
            // Arrange
            var binary         = DllTestHelper.CompileTestBinary(_folder);
            var expected       = false;
            var opCodeExpected = expectedOpCodeName.ParseOpCode();

            // Act
            var mutatedBinary =
                DllTestHelper.MutateMethod <BooleanBranchMutationAnalyzer>(binary, methodName, opCodeExpected, simplify);

            using (var binaryInteractor = new DllTestHelper(mutatedBinary))
            {
                var actual =
                    (bool)binaryInteractor.DynamicMethodCall(_nameSpace, methodName.FirstCharToUpper(),
                                                             new[] { argument1 });

                // Assert
                Assert.AreEqual(expected, actual);
            }
        }
Exemple #4
0
        public void Equality_PostMutation_Branch(string methodName, string defaultOpCodeName, string expectedOpCodeName,
                                                 object argument1, object argument2)
        {
            // Arrange
            var binary         = DllTestHelper.CompileTestBinary(_folder);
            var expected       = false;
            var opCodeDefault  = defaultOpCodeName.ParseOpCode();
            var opCodeExpected = expectedOpCodeName.ParseOpCode();

            // Act
            binary = Utils.Utils.ChangeComparisonToBranchOperator(binary, methodName, opCodeDefault);
            var mutatedBinary =
                DllTestHelper.MutateMethod <ComparisonMutationAnalyzer>(binary, methodName, opCodeExpected);

            using (var binaryInteractor = new DllTestHelper(mutatedBinary))
            {
                var instance = binaryInteractor.CreateInstance(_nameSpace);
                var method   = ((object)instance).GetType().GetMethod(methodName.FirstCharToUpper());
                var actual   = (bool)method.Invoke(instance, new[] { argument1, argument2 });

                // Assert
                Assert.AreEqual(expected, actual);
            }
        }