public void NullReferenceExceptionBugTest() { var source = new Addend(1); var target = new NullReferenceExceptionBug(); CalculatedProperty.Create( source.GetProperty(o => o.AddendValue), v => v, target.GetProperty(o => o.Value)).Dispose(); }
internal Exceptional() { AssertThrow <ArgumentNullException>( () => CalculatedProperty.Create((IProperty <NotifyPropertyChanged, int>)null, v => v, this.GetProperty(o => o.Calculated)).Dispose(), () => CalculatedProperty.Create(this.GetProperty(o => o.Value), null, this.GetProperty(o => o.Calculated)).Dispose(), () => CalculatedProperty.Create(this.GetProperty(o => o.Value), v => v, null).Dispose()); AssertThrow <ArgumentNullException>(() => MultiBinding.Create(this.GetProperty(o => o.Value), null).Dispose()); }
private static CalculatedProperty <int> CreateSum( IProperty <NotifyPropertyChanged, int> calculated, params Addend[] addends) { var ps = addends.Select(a => a.GetProperty(o => o.AddendValue)).ToArray(); switch (ps.Length) { case 1: return(CalculatedProperty.Create(ps[0], calculated)); case 2: return(CalculatedProperty.Create(ps[0], ps[1], (p1, p2) => p1 + p2, calculated)); case 3: return(CalculatedProperty.Create(ps[0], ps[1], ps[2], (p1, p2, p3) => p1 + p2 + p3, calculated)); case 4: return(CalculatedProperty.Create( ps[0], ps[1], ps[2], ps[3], (p1, p2, p3, p4) => p1 + p2 + p3 + p4, calculated)); case 5: return(CalculatedProperty.Create( ps[0], ps[1], ps[2], ps[3], ps[4], (p1, p2, p3, p4, p5) => p1 + p2 + p3 + p4 + p5, calculated)); case 6: return(CalculatedProperty.Create( ps[0], ps[1], ps[2], ps[3], ps[4], ps[5], (p1, p2, p3, p4, p5, p6) => p1 + p2 + p3 + p4 + p5 + p6, calculated)); case 7: return(CalculatedProperty.Create( ps[0], ps[1], ps[2], ps[3], ps[4], ps[5], ps[6], (p1, p2, p3, p4, p5, p6, p7) => p1 + p2 + p3 + p4 + p5 + p6 + p7, calculated)); case 8: return(CalculatedProperty.Create( ps[0], ps[1], ps[2], ps[3], ps[4], ps[5], ps[6], ps[7], (p1, p2, p3, p4, p5, p6, p7, p8) => p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8, calculated)); case 9: return(CalculatedProperty.Create( ps[0], ps[1], ps[2], ps[3], ps[4], ps[5], ps[6], ps[7], ps[8], (p1, p2, p3, p4, p5, p6, p7, p8, p9) => p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9, calculated)); case 10: return(CalculatedProperty.Create( ps[0], ps[1], ps[2], ps[3], ps[4], ps[5], ps[6], ps[7], ps[8], ps[9], (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) => p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10, calculated)); case 11: return(CalculatedProperty.Create( ps[0], ps[1], ps[2], ps[3], ps[4], ps[5], ps[6], ps[7], ps[8], ps[9], ps[10], (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) => p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9 + p10 + p11, calculated)); default: return(CalculatedProperty.Create(ps, vs => vs.Aggregate((a, r) => a + r), calculated)); } }