Exemplo n.º 1
0
        public void MapIncrement()
        {
            EnumDataset <int> ds    = new EnumDataset <int>(new int[] { 1, 2, 3 });
            IDataset <int>    mapds = ds.Map(i => i + 1);
            var enumerator          = mapds.GetEnumerator();

            for (int k = 1; enumerator.MoveNext(); k++)
            {
                Assert.AreEqual(k + 1, enumerator.Current);
            }

            Assert.AreEqual(3, mapds.Count());
        }
Exemplo n.º 2
0
        public void MapConcat()
        {
            TextDataset       ds    = new TextDataset("foo\nbar");
            IDataset <string> mapds = ds.Map(i => i + "a");
            var enumerator          = mapds.GetEnumerator();

            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual("fooa", enumerator.Current);

            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual("bara", enumerator.Current);

            Assert.IsFalse(enumerator.MoveNext());
            Assert.AreEqual(2, mapds.Count());
        }
Exemplo n.º 3
0
        public void FlatMap()
        {
            TextFileDataset   ds    = new TextFileDataset("Files\\Words.txt");
            IDataset <string> mapds = ds.FlatMap(i => i.Split(' '));
            var enumerator          = mapds.GetEnumerator();

            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual("foo", enumerator.Current);

            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual("bar", enumerator.Current);

            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual("zoo", enumerator.Current);

            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual("war", enumerator.Current);

            Assert.IsFalse(enumerator.MoveNext());
            Assert.AreEqual(4, mapds.Count());
        }