public void FindMatchesReturnsMatchWhenItemsAreDifferentTypeDefinitions() { var oldItem = new TestInterfaceDefinition(); var newItem = new TestClassDefinition().Set(x => { x.Namespace = oldItem.Namespace; x.RawName = oldItem.RawName; }); var oldItems = new List <ITypeDefinition> { oldItem }; var newItems = new List <ITypeDefinition> { newItem }; var sut = new TypeEvaluator(); var actual = sut.FindMatches(oldItems, newItems); actual.ItemsRemoved.Should().BeEmpty(); actual.ItemsAdded.Should().BeEmpty(); actual.MatchingItems.Should().HaveCount(1); var match = actual.MatchingItems.Single(); match.OldItem.Should().Be(oldItem); match.NewItem.Should().Be(newItem); }
public void CompareMatchReturnsBreakingChangeWhenTypeChangedToInterface() { var oldItem = new TestClassDefinition(); var newItem = new TestInterfaceDefinition(); var match = new ItemMatch <ITypeDefinition>(oldItem, newItem); var options = Model.Create <ComparerOptions>(); 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(); }
public void CompareMatchReturnsInterfaceComparerResult() { var oldItem = new TestInterfaceDefinition(); var newItem = new TestInterfaceDefinition(); var match = new ItemMatch <ITypeDefinition>(oldItem, newItem); var options = Model.Create <ComparerOptions>(); var changeType = Model.Create <SemVerChangeType>(); var message = Guid.NewGuid().ToString(); var result = new ComparisonResult(changeType, oldItem, newItem, message); var results = new[] { result }; Service <IInterfaceComparer>() .CompareMatch( Arg.Is <ItemMatch <IInterfaceDefinition> >(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().Be(result); }
public void CalculateChangesReturnsBreakingWhenAddingMethodToInterface() { var declaringType = new TestInterfaceDefinition(); var oldItems = Array.Empty <IMethodDefinition>(); var newItem = new TestMethodDefinition().Set(x => { x.IsVisible = true; x.DeclaringType = declaringType; }); var newItems = new List <IMethodDefinition> { newItem }; var options = ComparerOptions.Default; var matchResults = new MatchResults <IMethodDefinition>(Array.Empty <IMethodDefinition>(), newItems); Service <IMethodEvaluator>().FindMatches(oldItems, newItems).Returns(matchResults); var actual = SUT.CalculateChanges(oldItems, newItems, options).ToList(); actual.Should().HaveCount(1); actual[0].ChangeType.Should().Be(SemVerChangeType.Breaking); }