Beispiel #1
0
        public void GetMutatedDocument_WhenCallingOnAMethodInsideOtherMethodCall_ShouldNotReplaceWithEmptyStatement()
        {
            var tree = SyntaxFactory.ParseSyntaxTree(@"
                    class C { 
                        public void FirstMethod() { var i = m.CallMe(Hello()); var h = new MyObject(Hello(1)); } 
                    }");
            var root = tree.GetRoot();

            var mutator = new MethodCallMutator();
            var doc     = mutator.GetMutatedDocument(root, null);

            Assert.AreEqual(0, doc.Count);
        }
Beispiel #2
0
        public void GetMutatedDocument_WhenCallingOnAMethodOnAnObjectWithReturnValue_ShouldNotReplaceWithEmptyStatement()
        {
            var tree = SyntaxFactory.ParseSyntaxTree(@"
                    class C { 
                        public void FirstMethod() { var i = myObject.Hello(); } 
                    }");
            var root = tree.GetRoot();

            var mutator = new MethodCallMutator();
            var doc     = mutator.GetMutatedDocument(root, null);

            Assert.AreEqual(0, doc.Count);
        }
        public void GetMutatedDocument_WhenCallingOnAMethodWithoutReturnValueOnAnObject_ShouldReplaceWithEmptyStatement()
        {
            var tree = SyntaxFactory.ParseSyntaxTree(@"
                    class C { 
                        public void FirstMethod() { myObject.Hello(); } 
                    }");
            var root = tree.GetRoot();

            var mutator = new MethodCallMutator();
            var doc     = mutator.GetMutatedDocument(root, null);

            Assert.AreEqual(";", doc[0].MutationDetails.Mutation.ToString());
        }
Beispiel #4
0
        public void GetMutatedDocument_WhenCallingOnAMethodWithoutReturnValue_ShouldReplaceWithEmptyStatement()
        {
            var tree = SyntaxFactory.ParseSyntaxTree(@"
                    class C { 
                        public void FirstMethod() { Hello(); } 
                    }");
            var root = tree.GetRoot();

            var mutator = new MethodCallMutator();
            var doc     = mutator.GetMutatedDocument(root, null);

            Assert.AreEqual("/*Hello();*/", doc[0].MutationDetails.Mutation.ToFullString());
            Assert.AreEqual(MutationOperators.MethodCall.ToString(), doc[0].MutationDetails.Category.HeadCategory);
            Assert.AreEqual("InvocationExpression", doc[0].MutationDetails.Category.Subcategory);
        }