public void CompareReturnsReturnsChangeTypeWhenAtLeastOneItemHidden(bool firstItemVisible,
                                                                            bool secondItemVisible, SemVerChangeType?changeType)
        {
            var oldMember = new TestClassDefinition()
                            .Set(x => { x.IsVisible = firstItemVisible; });
            var newMember = oldMember.JsonClone()
                            .Set(x => { x.IsVisible = secondItemVisible; });
            var match   = new ItemMatch <IClassDefinition>(oldMember, newMember);
            var options = ComparerOptions.Default;

            var attributeProcessor = Substitute.For <IAttributeMatchProcessor>();

            var sut = new Wrapper <IClassDefinition>(attributeProcessor, null);

            var actual = sut.CompareMatch(match, options).ToList();

            _output.WriteResults(actual);

            if (changeType == null)
            {
                actual.Should().BeEmpty();
            }
            else
            {
                actual.Should().HaveCount(1);
                actual[0].ChangeType.Should().Be(changeType);
            }
        }
Пример #2
0
        public void CompareMatchReturnsBreakingWhenNamespaceChanged()
        {
            var oldItem = new TestClassDefinition();
            var newItem = oldItem.JsonClone().Set(x => x.Namespace = Guid.NewGuid().ToString());
            var match   = new ItemMatch <IClassDefinition>(oldItem, newItem);
            var options = ComparerOptions.Default;

            var actual = SUT.CompareMatch(match, options).ToList();

            _output.WriteResults(actual);

            actual.Should().HaveCount(1);

            actual[0].ChangeType.Should().Be(SemVerChangeType.Breaking);
            actual[0].Message.Should().NotBeNullOrWhiteSpace();
        }
Пример #3
0
        public void CompareMatchReturnsResultBasedOnImplementedTypeChanges(string oldTypes, string newTypes,
                                                                           int expected)
        {
            var oldImplementedTypes = oldTypes.Split(',', StringSplitOptions.RemoveEmptyEntries);
            var newImplementedTypes = newTypes.Split(',', StringSplitOptions.RemoveEmptyEntries);
            var oldItem             = new TestClassDefinition().Set(x => x.ImplementedTypes = oldImplementedTypes);
            var newItem             = oldItem.JsonClone().Set(x => x.ImplementedTypes = newImplementedTypes);
            var match   = new ItemMatch <IClassDefinition>(oldItem, newItem);
            var options = ComparerOptions.Default;

            var actual = SUT.CompareMatch(match, options).ToList();

            _output.WriteResults(actual);

            actual.Should().HaveCount(expected);
            actual.All(x => x.ChangeType == SemVerChangeType.Breaking).Should().BeTrue();
        }
        public void CompareMatchReturnsResultFromFieldMatchProcessor()
        {
            var oldItem    = new TestClassDefinition();
            var newItem    = oldItem.JsonClone();
            var match      = new ItemMatch <IClassDefinition>(oldItem, newItem);
            var options    = ComparerOptions.Default;
            var changeType = Model.Create <SemVerChangeType>();
            var message    = Guid.NewGuid().ToString();
            var result     = new ComparisonResult(changeType, oldItem, newItem, message);
            var results    = new[] { result };

            Service <IFieldMatchProcessor>()
            .CalculateChanges(oldItem.Fields,
                              newItem.Fields,
                              options).Returns(results);

            var actual = SUT.CompareMatch(match, options).ToList();

            _output.WriteResults(actual);

            actual.Should().HaveCount(1);
            actual[0].Should().BeEquivalentTo(result);
        }
Пример #5
0
        public void CompareMatchReturnsResultFromAccessModifiersComparer()
        {
            var oldItem    = new TestClassDefinition();
            var newItem    = oldItem.JsonClone();
            var match      = new ItemMatch <IClassDefinition>(oldItem, newItem);
            var options    = ComparerOptions.Default;
            var changeType = Model.Create <SemVerChangeType>();
            var message    = Guid.NewGuid().ToString();
            var result     = new ComparisonResult(changeType, oldItem, newItem, message);
            var results    = new[] { result };

            Service <IAccessModifiersComparer>()
            .CompareMatch(
                Arg.Is <ItemMatch <IAccessModifiersElement <AccessModifiers> > >(
                    x => x.OldItem == oldItem && x.NewItem == newItem),
                options).Returns(results);

            var actual = SUT.CompareMatch(match, options).ToList();

            _output.WriteResults(actual);

            actual.Should().HaveCount(1);
            actual[0].Should().BeEquivalentTo(result);
        }