Ejemplo n.º 1
0
        public async Task EvaluatesBreakingWhenAbstractPropertyAdded()
        {
            var oldCode = new List <CodeSource>
            {
                new(NoProperty)
            };
            var newCode = new List <CodeSource>
            {
                new(SingleProperty.Replace("public string MyProperty", "public abstract string MyProperty"))
            };

            var options = OptionsFactory.BuildOptions();

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

            result.ChangeType.Should().Be(SemVerChangeType.Breaking);
        }
Ejemplo n.º 2
0
        public async Task EvaluatesChangeOfModifiers(string oldModifiers, string newModifiers,
                                                     SemVerChangeType expected)
        {
            var oldCode = new List <CodeSource>
            {
                new(SingleProperty.Replace("string MyProperty", oldModifiers + " string MyProperty"))
            };
            var newCode = new List <CodeSource>
            {
                new(SingleProperty.Replace("string MyProperty", newModifiers + " string MyProperty"))
            };

            var options = OptionsFactory.BuildOptions();

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

            result.ChangeType.Should().Be(expected);
        }
Ejemplo n.º 3
0
        public async Task EvaluatesAddingSetAccessorWithAccessModifiers(
            string modifiers,
            SemVerChangeType expected)
        {
            var oldCode = new List <CodeSource>
            {
                new(SingleProperty.Replace("set;", string.Empty))
            };
            var newCode = new List <CodeSource>
            {
                new(SingleProperty.Replace("set;", modifiers + " set;"))
            };

            var options = OptionsFactory.BuildOptions();

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

            result.ChangeType.Should().Be(expected);
        }
Ejemplo n.º 4
0
        public async Task EvaluatesChangesToAttribute(string updatedValue,
                                                      AttributeCompareOption compareOption,
                                                      SemVerChangeType expected)
        {
            var oldCode = new List <CodeSource>
            {
                new(SingleProperty)
            };
            var newCode = new List <CodeSource>
            {
                new(SingleProperty.Replace("[PropertyAttribute(344, true, myName: \"on the property\")]",
                                           updatedValue))
            };

            var options = OptionsFactory.BuildOptions().Set(x => x.CompareAttributes = compareOption);

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

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