public void GivenValidNestedStructure_WhenValidateRecursively_ThenCorrectValidationResults() { RecursiveValidator validator = new RecursiveValidator(null); List <ValidationResult> results = validator.ValidateObjectRecursively(NestedList.Valid()); Assert.Empty(results); }
public int IndexOf(object value) { int index = CustomRows.IndexOf(value); if (index == -1) return NestedList.IndexOf(value); return index + NestedList.Count; }
public void GivenInvalidChild_WhenValidateRecursively_ThenCorrectValidationResults() { RecursiveValidator validator = new RecursiveValidator(null); List <ValidationResult> results = validator.ValidateObjectRecursively(NestedList.WithInvalidChild()); Assert.Equal(3, results.Count); ValidationResultUtility.AssertValidationResultEquals(results[0], "The RequiredString field is required.", "Child[0].RequiredString"); ValidationResultUtility.AssertValidationResultEquals(results[1], "The RequiredLong field is required.", "Child[0].RequiredLong"); ValidationResultUtility.AssertValidationResultEquals(results[2], "The RequiredUnsignedLong field is required.", "Child[0].RequiredUnsignedLong"); }
public static DelegateFilterBuilder MatchItem <TListItem>(this NestedList <TListItem> value, Expression <Func <TListItem, Filter> > filterExpression) { return(new DelegateExpressionFilterBuilder <TListItem>(filterExpression, filter => x => { // As the path must be absolute nested NestedFilters must have the path prepended PrependPathOnNestedFilters(x, filter); return new NestedFilter(x, filter); })); }
public void Reset() { progress = 0; total = 0; size = 0; current = new NestedList <Entry>(); next = new NestedList <Entry>(); left = new List <Entry>(); right = new List <Entry>(); sorted = new List <Entry>(); }
public void SerializeNestedList() { var list1 = new SomeList() { new ListItem("aaa"), new ListItem("bbb") }; var list2 = new SomeList() { new ListItem("ccc"), new ListItem("ddd") }; var nestedList = new NestedList(); nestedList.Add(list1); nestedList.Add(list2); Serializer.Serialize(Stream.Null, nestedList); }
public int LoopCount(int n) { if (n < 2) { return(0); } int count = 0; List <int> current = new List <int>(n); List <int> next = new List <int>(n); for (int i = 0; i < n; i++) { current.Add(1); } while (true) { if (current.Count > 1) { int sum = current[0] + current[1]; count += sum - 1; next.Add(sum); current.RemoveRange(0, 2); } else if (current.Count > 0) { int sum = current[0]; next.Add(sum); current.RemoveAt(0); } else { if (next[0] == n) { return(count); } current = new List <int>(next); next.Clear(); } } }
public Team(string name) { TeamName = name; Players = new NestedList<Player>(); }
public League(string name) { LeagueName = name; Teams = new NestedList<Team>(); }
public Department(string name) { Name = name; Employees = new NestedList <Employee>(); }
public Company(string name) { Name = name; Departments = new NestedList <Department>(); }
public Team(string name) { TeamName = name; Players = new NestedList <Player>(); }
public League(string name) { LeagueName = name; Teams = new NestedList <Team>(); }
public Department(string name) { Name = name; Employees = new NestedList<Employee>(); }
public Company(string name) { Name = name; Departments = new NestedList<Department>(); }