public void Add_WhenPathFilteringIsNotEnabled_ShouldSetCompleteSegmentData() { // Arrange var settingsMock = A.Fake <IParsingSettings>(); A.CallTo(() => settingsMock.IsPathFilteringEnabled).Returns(false); var testee = new SegmentDataCollector(settingsMock); // Act testee.Add("The test path", "The test value"); // Assert testee.CompleteSegmentData.Should().NotBeNull(); testee.CompleteSegmentData.SourcePath.Should().Be("The test path"); testee.CompleteSegmentData.SourceValue.Should().Be("The test value"); testee.CompleteSegmentData.TargetPath.Should().Be("The test path"); testee.CompleteSegmentData.TargetValue.Should().Be(string.Empty); }
public void Add_WhenPathFilteringIsEnabled_ShouldSetCompleteSegmentDataWhenComplete(TestCase testCase) { // Arrange var settingsMock = A.Fake <IParsingSettings>(); A.CallTo(() => settingsMock.IsPathFilteringEnabled).Returns(true); A.CallTo(() => settingsMock.PathRules) .Returns(testCase.PathRules); var testee = new SegmentDataCollector(settingsMock); // Act for (var i = 0; i < testCase.AddChecks.Count; i++) { var addCheck = testCase.AddChecks[i]; testee.Add(addCheck.Path, addCheck.Value); // Assert if (addCheck.ExpectedSegmentData == null) { testee.CompleteSegmentData.Should().BeNull($"because AddCheck #{i} expected segment data is null"); } else { testee.CompleteSegmentData.Should() .NotBeNull($"because AddCheck #{i} expected segment data is not null"); testee.CompleteSegmentData.SourcePath.Should() .Be(addCheck.ExpectedSegmentData.SourcePath, $"because AddCheck #{i} expected segment SourcePath"); testee.CompleteSegmentData.SourceValue.Should() .Be(addCheck.ExpectedSegmentData.SourceValue, $"because AddCheck #{i} expected segment SourceValue"); testee.CompleteSegmentData.TargetPath.Should() .Be(addCheck.ExpectedSegmentData.TargetPath, $"because AddCheck #{i} expected segment TargetPath"); testee.CompleteSegmentData.TargetValue.Should() .Be(addCheck.ExpectedSegmentData.TargetValue, $"because AddCheck #{i} expected segment TargetValue"); } } }