public void ConcatNew_ConcatPartial_ShouldConcatFullChain(params string[][] parms) { // arrange var extraPath = new CodePath(); var sut = new CodePath(); foreach (var name in parms[0]) { var mockedMethod = Mock.Create <Method>(); Mock.Arrange(() => mockedMethod.FullName).Returns(name); sut.AddLast(mockedMethod); } foreach (var name in parms[1]) { var mockedMethod = Mock.Create <Method>(); Mock.Arrange(() => mockedMethod.FullName).Returns(name); extraPath.AddLast(mockedMethod); } // form expected final path var expected = parms[0].Concat(parms[1].Skip(2)); // act var newSut = sut.ConcatNew(extraPath.GetSubPaths().ToList()[1]); // assert Assert.Equal(parms[0].Length + parms[1].Length - 2, newSut.Count()); Assert.Equal(parms[0].Length + parms[1].Length - 2, newSut.Length); Assert.Equal(expected, newSut.Select(x => x.FullName)); }
public void GetSubPaths_SubPathsHaveValidProperties(params string[] parms) { // arrange var sut = new CodePath(); foreach (var name in parms) { var mockedMethod = Mock.Create <Method>(); Mock.Arrange(() => mockedMethod.FullName).Returns(name); sut.AddLast(mockedMethod); } // act var subPathsList = sut.GetSubPaths().ToList(); // assert for (int i = 0; i < subPathsList.Count; i++) { var currentPath = subPathsList[i]; Assert.Equal(sut.Length - i - 1, currentPath.Length); Assert.Equal(sut.ElementAt(i + 1), currentPath.FirstMethod); Assert.Equal(sut.LastMethod, currentPath.LastMethod); } }