public void WhenOneLevelThenPropertyPathItself() { var path0 = new PropertyPath(null, ConfOrm.ForClass <MyClass> .Property(x => x.Component)); var actual = path0.InverseProgressivePath().ToList(); actual.Count.Should().Be(1); actual.Single().Should().Be(path0); }
public void WhenTwoLevelsThen2PropertyPaths() { // x.Component.Something0 var path0 = new PropertyPath(null, ConfOrm.ForClass <MyClass> .Property(x => x.Component)); var path1 = new PropertyPath(path0, ConfOrm.ForClass <ComponentLevel0> .Property(x => x.Something0)); var actual = path1.InverseProgressivePath().ToList(); actual.Count.Should().Be(2); var expected1 = new PropertyPath(null, ConfOrm.ForClass <ComponentLevel0> .Property(x => x.Something0)); var expected2 = path1; actual.First().Should().Be(expected1); actual.Skip(1).First().Should().Be(expected2); }
public void WhenThreeLevelsThen3PropertyPaths() { // x.Component.ComponentLevel1.Something1 var path0 = new PropertyPath(null, ConfOrm.ForClass <MyClass> .Property(x => x.Component)); var path1 = new PropertyPath(path0, ConfOrm.ForClass <ComponentLevel0> .Property(x => x.ComponentLevel1)); var path2 = new PropertyPath(path1, ConfOrm.ForClass <ComponentLevel1> .Property(x => x.Something1)); var actual = path2.InverseProgressivePath().ToList(); actual.Count.Should().Be(3); var expected1 = new PropertyPath(null, ConfOrm.ForClass <ComponentLevel1> .Property(x => x.Something1)); var expected2 = new PropertyPath(new PropertyPath(null, ConfOrm.ForClass <ComponentLevel0> .Property(x => x.ComponentLevel1)), ConfOrm.ForClass <ComponentLevel1> .Property(x => x.Something1)); var expected3 = path2; actual.First().Should().Be(expected1); actual.Skip(1).First().Should().Be(expected2); actual.Skip(2).First().Should().Be(expected3); }
public void WhenFourLevelsThen4PropertyPaths() { // x.Component.ComponentLevel1.ComponentLevel2.Something2 var path0 = new PropertyPath(null, ConfOrm.ForClass <MyClass> .Property(x => x.Component)); var path1 = new PropertyPath(path0, ConfOrm.ForClass <ComponentLevel0> .Property(x => x.ComponentLevel1)); var path2 = new PropertyPath(path1, ConfOrm.ForClass <ComponentLevel1> .Property(x => x.ComponentLevel2)); var path3 = new PropertyPath(path2, ConfOrm.ForClass <ComponentLevel2> .Property(x => x.Something2)); var actual = path3.InverseProgressivePath().ToList(); actual.Count.Should().Be(4); var expected1 = new PropertyPath(null, ConfOrm.ForClass <ComponentLevel2> .Property(x => x.Something2)); var expected2 = new PropertyPath(new PropertyPath(null, ConfOrm.ForClass <ComponentLevel1> .Property(x => x.ComponentLevel2)), ConfOrm.ForClass <ComponentLevel2> .Property(x => x.Something2)); var expected3 = new PropertyPath(new PropertyPath(new PropertyPath(null, ConfOrm.ForClass <ComponentLevel0> .Property(x => x.ComponentLevel1)), ConfOrm.ForClass <ComponentLevel1> .Property(x => x.ComponentLevel2)), ConfOrm.ForClass <ComponentLevel2> .Property(x => x.Something2)); var expected4 = path3; actual.First().Should().Be(expected1); actual.Skip(1).First().Should().Be(expected2); actual.Skip(2).First().Should().Be(expected3); actual.Skip(3).First().Should().Be(expected4); }