public void CompareMatchReturnsResultFromParameterComparer() { var oldParameter = new TestParameterDefinition(); var oldParameters = new List <IParameterDefinition> { oldParameter }.AsReadOnly(); var oldItem = new TestMethodDefinition().Set(x => x.Parameters = oldParameters); var newParameter = new TestParameterDefinition(); var newParameters = new List <IParameterDefinition> { newParameter }.AsReadOnly(); var newItem = oldItem.JsonClone().Set(x => x.Parameters = newParameters); var match = new ItemMatch <IMethodDefinition>(oldItem, newItem); var changeType = Model.Create <SemVerChangeType>(); var message = Guid.NewGuid().ToString(); var result = new ComparisonResult(changeType, oldItem, newItem, message); var results = new[] { result }; var options = ComparerOptions.Default; Service <IParameterComparer>() .CompareMatch( Arg.Is <ItemMatch <IParameterDefinition> >(x => x.OldItem == oldParameter && x.NewItem == newParameter), options).Returns(results); var actual = SUT.CompareMatch(match, options).ToList(); _output.WriteResults(actual); actual.Should().HaveCount(1); actual[0].Should().BeEquivalentTo(result); }
public void CompareMatchReturnsEmptyWhenNoChangesFound() { var oldItem = new TestParameterDefinition(); var newItem = oldItem.JsonClone(); var match = new ItemMatch <IParameterDefinition>(oldItem, newItem); var options = ComparerOptions.Default; var actual = SUT.CompareMatch(match, options).ToList(); _output.WriteResults(actual); actual.Should().BeEmpty(); }
public void CompareMatchReturnsBreakingWhenTypeChanged() { var oldItem = new TestParameterDefinition(); var newItem = oldItem.JsonClone().Set(x => x.Type = "NewType"); var match = new ItemMatch <IParameterDefinition>(oldItem, newItem); var options = ComparerOptions.Default; var actual = SUT.CompareMatch(match, options).ToList(); _output.WriteResults(actual); actual.Should().HaveCount(1); actual[0].ChangeType.Should().BeEquivalentTo(SemVerChangeType.Breaking); }
public void CompareMatchReturnsBreakingWhenParameterRemoved() { var parameter = new TestParameterDefinition(); var parameters = new List <IParameterDefinition> { parameter }.AsReadOnly(); var oldItem = new TestMethodDefinition().Set(x => x.Parameters = parameters); var newItem = oldItem.JsonClone().Set(x => x.Parameters = Array.Empty <IParameterDefinition>()); var match = new ItemMatch <IMethodDefinition>(oldItem, newItem); var options = ComparerOptions.Default; var actual = SUT.CompareMatch(match, options).ToList(); _output.WriteResults(actual); actual.Should().HaveCount(1); actual[0].ChangeType.Should().BeEquivalentTo(SemVerChangeType.Breaking); actual[0].Message.Should().Contain("removed"); actual[0].Message.Should().Contain("parameter"); }
public void CompareMatchReturnsResultBasedOnDefaultValueChanges(string oldValue, string newValue, SemVerChangeType?expected) { var oldItem = new TestParameterDefinition().Set(x => x.DefaultValue = oldValue); var newItem = oldItem.JsonClone().Set(x => x.DefaultValue = newValue); var match = new ItemMatch <IParameterDefinition>(oldItem, newItem); var options = ComparerOptions.Default; var actual = SUT.CompareMatch(match, options).ToList(); _output.WriteResults(actual); if (expected == null) { actual.Should().BeEmpty(); } else { actual.Should().HaveCount(1); actual[0].ChangeType.Should().BeEquivalentTo(expected); } }
public void CompareMatchReturnsResultFromParameterModifierComparer() { var item = new TestParameterDefinition(); var match = new ItemMatch <IParameterDefinition>(item, item); var options = ComparerOptions.Default; var changeType = Model.Create <SemVerChangeType>(); var message = Guid.NewGuid().ToString(); var result = new ComparisonResult(changeType, item, item, message); var results = new[] { result }; Service <IParameterModifiersComparer>() .CompareMatch( Arg.Is <ItemMatch <IModifiersElement <ParameterModifiers> > >( x => x.OldItem == item && x.NewItem == item), options).Returns(results); var actual = SUT.CompareMatch(match, options).ToList(); _output.WriteResults(actual); actual.Should().HaveCount(1); actual[0].Should().BeEquivalentTo(result); }