public void testObjectFilter() { var _Starts = new List<String>() { "marko", "josh", "peter" }; var _Pipe = new ObjectFilterPipe<String>("marko", ComparisonFilter.EQUAL); _Pipe.SetSource(_Starts.GetEnumerator()); int _Counter = 0; while (_Pipe.MoveNext()) { var next = _Pipe.Current; Assert.IsTrue(next.Equals("josh") || next.Equals("peter")); _Counter++; } Assert.AreEqual(2, _Counter); _Pipe = new ObjectFilterPipe<String>("marko", ComparisonFilter.NOT_EQUAL); _Pipe.SetSource(_Starts.GetEnumerator()); _Counter = 0; while (_Pipe.MoveNext()) { var next = _Pipe.Current; Assert.IsTrue(next.Equals("marko")); _Counter++; } Assert.AreEqual(1, _Counter); }
public void testNumericComparisons() { var _Starts = new List<Int32>() { 32, 1, 7 }; var _Pipe = new ObjectFilterPipe<Int32>(6, ComparisonFilter.GREATER_THAN); _Pipe.SetSource(_Starts.GetEnumerator()); int _Counter = 0; while (_Pipe.MoveNext()) { var next = _Pipe.Current; Assert.IsTrue(next.Equals(1)); _Counter++; } Assert.AreEqual(1, _Counter); // ----------------------- _Pipe = new ObjectFilterPipe<Int32>(8, ComparisonFilter.GREATER_THAN_EQUAL); _Pipe.SetSource(_Starts.GetEnumerator()); _Counter = 0; while (_Pipe.MoveNext()) { var next = _Pipe.Current; Assert.IsTrue(next.Equals(1) || next.Equals(7)); _Counter++; } Assert.AreEqual(2, _Counter); // ----------------------- _Pipe = new ObjectFilterPipe<Int32>(8, ComparisonFilter.LESS_THAN); _Pipe.SetSource(_Starts.GetEnumerator()); _Counter = 0; while (_Pipe.MoveNext()) { var next = _Pipe.Current; Assert.IsTrue(next.Equals(32)); _Counter++; } Assert.AreEqual(1, _Counter); // ----------------------- _Pipe = new ObjectFilterPipe<Int32>(6, ComparisonFilter.LESS_THAN_EQUAL); _Pipe.SetSource(_Starts.GetEnumerator()); _Counter = 0; while (_Pipe.MoveNext()) { var next = _Pipe.Current; Assert.IsTrue(next.Equals(7) || next.Equals(32)); _Counter++; } Assert.AreEqual(2, _Counter); }