Exemplo n.º 1
0
        public void ReduceTestCase()
        {
            var parameters = new List <string>();
            var partition1 = "[[\"a\", 1],[\"word\", 1],[\"and\", 1],[\"another\", 1],[\"word\", 1],[\"in\", 1],[\"a\", 1],[\"sentence\", 1]]";
            var partition2 = "[[\"a\", 1],[\"word\", 1],[\"and\", 1],[\"another\", 1],[\"in\", 1],[\"a\", 1],[\"sentence\", 1]]";

            parameters.Add(partition1);
            parameters.Add(partition2);

            var reduce = new Reduce();

            reduce.SetInParameters(parameters);
            reduce.pHandler = null;             // Disable the persistence handler

            reduce.Execute();

            var result = reduce.Result as Dictionary <string, int>;

            Assert.True(result.ContainsKey("a"));
            Assert.AreEqual(4, result["a"]);
            Assert.True(result.ContainsKey("word"));
            Assert.AreEqual(3, result["word"]);
            Assert.True(result.ContainsKey("and"));
            Assert.AreEqual(2, result["and"]);
            Assert.True(result.ContainsKey("another"));
            Assert.AreEqual(2, result["another"]);
            Assert.True(result.ContainsKey("in"));
            Assert.AreEqual(2, result["in"]);
            Assert.True(result.ContainsKey("sentence"));
            Assert.AreEqual(2, result["sentence"]);

            // Something that doesn occurr
            Assert.False(result.ContainsKey("jesus"));
        }