public void AggregateWithSeed() { int[] ints = { 4, 8, 8, 3, 9, 0, 7, 8, 2 }; DataProducer <int> subject = new DataProducer <int>(); // Count the even numbers in the array, using a seed value of 0. IFuture <int> result = subject.Aggregate (0, (total, next) => next % 2 == 0 ? total + 1 : total); subject.ProduceAndEnd(ints); Assert.AreEqual(6, result.Value); }
public void AggregateWithSeedAndTranslation() { string[] fruits = { "apple", "mango", "orange", "passionfruit", "grape" }; DataProducer <string> subject = new DataProducer <string>(); IFuture <string> result = subject.Aggregate ("banana", (longest, next) => next.Length > longest.Length ? next : longest, // Return the final result as an upper case string. fruit => fruit.ToUpper()); subject.ProduceAndEnd(fruits); Assert.AreEqual("PASSIONFRUIT", result.Value); }
public void AggregateNoSeed() { string sentence = "the quick brown fox jumps over the lazy dog"; // Split the string into individual words. string[] words = sentence.Split(' '); DataProducer <string> subject = new DataProducer <string>(); // Prepend each word to the beginning of the // new sentence to reverse the word order. IFuture <string> reversed = subject.Aggregate((workingSentence, next) => next + " " + workingSentence); subject.ProduceAndEnd(words); Assert.AreEqual("dog lazy the over jumps fox brown quick the", reversed.Value); }
public void AggregateNoSeed() { string sentence = "the quick brown fox jumps over the lazy dog"; // Split the string into individual words. string[] words = sentence.Split(' '); DataProducer<string> subject = new DataProducer<string>(); // Prepend each word to the beginning of the // new sentence to reverse the word order. IFuture<string> reversed = subject.Aggregate((workingSentence, next) => next + " " + workingSentence); subject.ProduceAndEnd(words); Assert.AreEqual("dog lazy the over jumps fox brown quick the", reversed.Value); }
public void AggregateWithSeed() { int[] ints = { 4, 8, 8, 3, 9, 0, 7, 8, 2 }; DataProducer<int> subject = new DataProducer<int>(); // Count the even numbers in the array, using a seed value of 0. IFuture<int> result = subject.Aggregate (0, (total, next) => next % 2 == 0 ? total + 1 : total); subject.ProduceAndEnd(ints); Assert.AreEqual(6, result.Value); }
public void AggregateWithSeedAndTranslation() { string[] fruits = { "apple", "mango", "orange", "passionfruit", "grape" }; DataProducer<string> subject = new DataProducer<string>(); IFuture<string> result = subject.Aggregate ("banana", (longest, next) => next.Length > longest.Length ? next : longest, // Return the final result as an upper case string. fruit => fruit.ToUpper()); subject.ProduceAndEnd(fruits); Assert.AreEqual("PASSIONFRUIT", result.Value); }