public void Exists()
        {
            ReadWriteTestCollection <double> coll1 = new ReadWriteTestCollection <double>(new double[] { 4.5, 1.2, 7.6, -7.6, -0.04, 1.78, 10.11, 187.4 });

            Assert.IsTrue(coll1.Exists(delegate(double d) { return(d > 100); }));
            Assert.IsTrue(coll1.Exists(delegate(double d) { return(Math.Abs(d) == 0.04); }));
            Assert.IsFalse(coll1.Exists(delegate(double d) { return(d < -10.0); }));
            coll1.Clear();
            Assert.IsFalse(coll1.Exists(delegate(double d) { return(Math.Abs(d) == 0.04); }));

            ReadOnlyTestCollection <double> coll2 = new ReadOnlyTestCollection <double>(new double[] { 4.5, 1.2, 7.6, -7.6, -0.04, 1.78, 10.11, 187.4 });

            Assert.IsTrue(coll2.Exists(delegate(double d) { return(d > 100); }));
            Assert.IsTrue(coll2.Exists(delegate(double d) { return(Math.Abs(d) == 0.04); }));
            Assert.IsFalse(coll2.Exists(delegate(double d) { return(d < -10.0); }));
            coll2 = new ReadOnlyTestCollection <double>(new double[] {  });
            Assert.IsFalse(coll2.Exists(delegate(double d) { return(Math.Abs(d) == 0.04); }));
        }
        public void CountWhere()
        {
            ReadWriteTestCollection <double> coll1 = new ReadWriteTestCollection <double>(new double[] { 4.5, 1.2, 7.6, -7.6, -0.04, 1.78, 10.11, 187.4 });

            Assert.AreEqual(0, coll1.CountWhere(delegate(double d) { return(d > 200); }));
            Assert.AreEqual(6, coll1.CountWhere(delegate(double d) { return(Math.Abs(d) < 10); }));
            Assert.AreEqual(8, coll1.CountWhere(delegate(double d) { return(d > -10); }));
            Assert.AreEqual(4, coll1.CountWhere(delegate(double d) { return(Math.Abs(d) > 5); }));
            coll1.Clear();
            Assert.AreEqual(0, coll1.CountWhere(delegate(double d) { return(Math.Abs(d) < 10); }));

            ReadOnlyTestCollection <double> coll2 = new ReadOnlyTestCollection <double>(new double[] { 4.5, 1.2, 7.6, -7.6, -0.04, 1.78, 10.11, 187.4 });

            Assert.AreEqual(0, coll2.CountWhere(delegate(double d) { return(d > 200); }));
            Assert.AreEqual(6, coll2.CountWhere(delegate(double d) { return(Math.Abs(d) < 10); }));
            Assert.AreEqual(8, coll2.CountWhere(delegate(double d) { return(d > -10); }));
            Assert.AreEqual(4, coll2.CountWhere(delegate(double d) { return(Math.Abs(d) > 5); }));
            coll2 = new ReadOnlyTestCollection <double>(new double[] { });
            Assert.AreEqual(0, coll2.CountWhere(delegate(double d) { return(Math.Abs(d) < 10); }));
        }
Example #3
0
        public void TrueForAll()
        {
            ReadWriteTestCollection <double> coll1 = new ReadWriteTestCollection <double>(new double[] { 4.5, 1.2, 7.6, -7.6, -0.04, 1.78, 10.11, 187.4 });

            Assert.IsFalse(coll1.TrueForAll(d => d > 100));
            Assert.IsFalse(coll1.TrueForAll(d => Math.Abs(d) < 10));
            Assert.IsTrue(coll1.TrueForAll(d => d > -10));
            Assert.IsTrue(coll1.TrueForAll(d => Math.Abs(d) < 200));
            coll1.Clear();
            Assert.IsTrue(coll1.TrueForAll(d => Math.Abs(d) == 0.04));

            ReadOnlyTestCollection <double> coll2 = new ReadOnlyTestCollection <double>(new double[] { 4.5, 1.2, 7.6, -7.6, -0.04, 1.78, 10.11, 187.4 });

            Assert.IsFalse(coll2.TrueForAll(d => d > 100));
            Assert.IsFalse(coll2.TrueForAll(d => Math.Abs(d) < 10));
            Assert.IsTrue(coll2.TrueForAll(d => d > -10));
            Assert.IsTrue(coll2.TrueForAll(d => Math.Abs(d) < 200));
            coll2 = new ReadOnlyTestCollection <double>(new double[] { });
            Assert.IsTrue(coll2.TrueForAll(d => Math.Abs(d) == 0.04));
        }