public Property InterleaveProperty(IList <int> xs, IList <int> ys) { var res = Interleaving.Interleave(xs, ys); var idxs = Enumerable.Range(0, Math.Min(xs.Count, ys.Count)).ToList(); return(PropExtensions.AndAll( PropExtensions.Label(xs.Count + ys.Count == res.Count(), "length"), PropExtensions.Label(xs.SequenceEqual(idxs.Select(idx => res[2 * idx]).Concat(res.Skip(2 * ys.Count))), "zip xs"), PropExtensions.Label(ys.SequenceEqual(idxs.Select(idx => res[2 * idx + 1]).Concat(res.Skip(2 * xs.Count))), "zip ys"))); }
public void InterleaveTest() { var body = FSharpFunc <IList <int>, FSharpFunc <IList <int>, Property> > .FromConverter(xs => FSharpFunc <IList <int>, Property> .FromConverter(ys => { var res = Interleaving.Interleave(xs, ys); var idxs = Enumerable.Range(0, Math.Min(xs.Count, ys.Count)).ToList(); return(PropExtensions.AndAll( PropExtensions.Label(xs.Count + ys.Count == res.Count(), "length"), PropExtensions.Label(xs.SequenceEqual(idxs.Select(idx => res[2 * idx]).Concat(res.Skip(2 * ys.Count))), "zip xs"), PropExtensions.Label(ys.SequenceEqual(idxs.Select(idx => res[2 * idx + 1]).Concat(res.Skip(2 * xs.Count))), "zip ys"))); })); Check.One(Config, body); }