public void TestReduce() { var data = new DataForProcessing(); var dataForReduce = new List <List <KeyValuePair <string, int> > > { new List <KeyValuePair <string, int> > { new KeyValuePair <string, int>("Hello", 1), new KeyValuePair <string, int>("Hello", 1) }, new List <KeyValuePair <string, int> > { new KeyValuePair <string, int>("world", 1) }, new List <KeyValuePair <string, int> > { new KeyValuePair <string, int>("my", 1) }, new List <KeyValuePair <string, int> > { new KeyValuePair <string, int>("friend", 1) } }; var result = new List <KeyValuePair <string, int> > { new KeyValuePair <string, int>("Hello", 2), new KeyValuePair <string, int>("world", 1), new KeyValuePair <string, int>("my", 1), new KeyValuePair <string, int>("friend", 1) }; var actual = data.Reduce(dataForReduce); CollectionAssert.AreEqual(result, actual); }
public List <KeyValuePair <string, int> > ReceiveDataForReduce(DataForProcessing testData, List <List <KeyValuePair <string, int> > > dataAfterMap, string type) { var res = new List <KeyValuePair <string, int> >(); if (type == "reducer") { res = testData.Reduce(dataAfterMap); } Console.WriteLine("'Reduce' operation has finished."); return(res); }