public void CompareMatchThrowsExceptionWhenTypedChangedToUnsupportedType() { var oldItem = new TestStructDefinition(); var newItem = Substitute.For <ITypeDefinition>(); var match = new ItemMatch <ITypeDefinition>(oldItem, newItem); var options = Model.Create <ComparerOptions>(); Action action = () => SUT.CompareMatch(match, options); action.Should().Throw <NotSupportedException>(); }
public void CompareMatchReturnsBreakingChangeWhenTypeChangedToStruct() { var oldItem = new TestClassDefinition(); var newItem = new TestStructDefinition(); 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 CompareMatchReturnsResultFromStructModifierComparer() { var item = new TestStructDefinition(); var match = new ItemMatch <IStructDefinition>(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 <IStructModifiersComparer>() .CompareMatch( Arg.Is <ItemMatch <IModifiersElement <StructModifiers> > >(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); }
public void CompareMatchReturnsResultFromFieldMatchProcessor() { var oldItem = new TestStructDefinition(); var newItem = oldItem.JsonClone(); var match = new ItemMatch <IStructDefinition>(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); }
public void CompareMatchReturnsStructComparerResult() { var oldItem = new TestStructDefinition(); var newItem = new TestStructDefinition(); 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 <IStructComparer>() .CompareMatch(Arg.Is <ItemMatch <IStructDefinition> >(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); }