Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }