Пример #1
0
        public async Task EvaluatesChangeOfGenericTypeDefinitionsOnDeclaringType(
            string oldClass,
            string newClass,
            string oldSignature,
            string newSignature,
            SemVerChangeType expected)
        {
            var oldCode = new List <CodeSource>
            {
                new(NoParameters
                    .Replace("public class MyClass", "public class " + oldClass)
                    .Replace("public string MyMethod()", "public string " + oldSignature))
            };
            var newCode = new List <CodeSource>
            {
                new(NoParameters
                    .Replace("public class MyClass", "public class " + newClass)
                    .Replace("public string MyMethod()", "public string " + newSignature))
            };

            var options = OptionsFactory.BuildOptions();

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(expected);
        }
Пример #2
0
        public async Task EvaluatesBreakingWhenAbstractMethodAdded()
        {
            var oldCode = new List <CodeSource>
            {
                new(NoMethod)
            };
            var newCode = new List <CodeSource>
            {
                new(NoParameters.Replace("public string MyMethod", "public abstract string MyMethod"))
            };

            var options = OptionsFactory.BuildOptions();

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(SemVerChangeType.Breaking);
        }
Пример #3
0
        public void Test_Help()
        {
            // Make sure it works for the command line descriptor without parameters.
            NoParameters cmdLine1 = new NoParameters();

            string[] args = new string[] { "-?" };
            Assert.IsFalse(Parser.ParseArgumentsWithUsage(args, cmdLine1));
            args = new string[] { "--help" };
            Assert.IsFalse(Parser.ParseArgumentsWithUsage(args, cmdLine1));

            // Make sure it works for the command line descriptor with some parameters.
            BoolParameters cmdLine2 = new BoolParameters();

            args = new string[] { "-?" };
            Assert.IsFalse(Parser.ParseArgumentsWithUsage(args, cmdLine2));
            args = new string[] { "--help" };
            Assert.IsFalse(Parser.ParseArgumentsWithUsage(args, cmdLine2));
        }
Пример #4
0
        public async Task EvaluatesChangeOfAccessModifiers(
            string oldModifiers,
            string newModifiers,
            SemVerChangeType expected)
        {
            var oldCode = new List <CodeSource>
            {
                new(NoParameters.Replace("public string MyMethod", oldModifiers + " string MyMethod"))
            };
            var newCode = new List <CodeSource>
            {
                new(NoParameters.Replace("public string MyMethod", newModifiers + " string MyMethod"))
            };

            var options = OptionsFactory.BuildOptions();

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(expected);
        }
Пример #5
0
        public async Task EvaluatesChangeOfReturnType(
            string oldValue,
            string newValue,
            SemVerChangeType expected)
        {
            var oldCode = new List <CodeSource>
            {
                new(NoParameters.Replace("public string MyMethod()", "public " + oldValue + "()"))
            };
            var newCode = new List <CodeSource>
            {
                new(NoParameters.Replace("public string MyMethod()", "public " + newValue + "()"))
            };

            var options = OptionsFactory.BuildOptions();

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(expected);
        }
Пример #6
0
        public async Task EvaluatesChangeOfMethodAttribute(
            string oldAttribute,
            string newAttribute,
            AttributeCompareOption compareOptions,
            SemVerChangeType expected)
        {
            var oldCode = new List <CodeSource>
            {
                new(NoParameters.Replace("public string MyMethod", oldAttribute + " public string MyMethod"))
            };
            var newCode = new List <CodeSource>
            {
                new(NoParameters.Replace("public string MyMethod", newAttribute + " public string MyMethod"))
            };

            var options = OptionsFactory.BuildOptions();

            options.CompareAttributes = compareOptions;

            var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None)
                         .ConfigureAwait(false);

            result.ChangeType.Should().Be(expected);
        }