private void DoIt(TextBox tb) { var col = new EnumerableActor <Tuple <int, int> >(); var tbActor = new TextBoxActor(tb); // fill our collection for (int i = 0; i <= 100000; i++) { col.Add(Tuple.Create(i % 100, i)); } tbActor.SendMessage(col.Count.ToString()); // apply some linq things var map = from item in col select Tuple.Create(item.Item1.ToString(), item.Item2); // regroup var regroup = from item in map group item by item.Item1 into g select g; // reduce var reduce = from item in regroup select Tuple.Create(item.Key, item.Sum(t => t.Item2)); // reduce 2 var reduce2 = reduce.AsActorQueryiable(); // project foreach (var item in reduce2) { tbActor.SendMessage(item.Item1 + " - " + item.Item2.ToString()); } }
public void GetEnumeratorTest() { TestLauncherActor.Test(() => { var act = new EnumerableActor <string>(); act.Add("test1"); act.Add("test2"); var list = new List <string>(); foreach (var item in act) { list.Add(item); } Assert.AreEqual(2, list.Count); Assert.AreEqual(2, act.Count()); }); }
public void QueryiableTest() { var col = new EnumerableActor <int>(); int expected = 0; for (int i = 0; i <= 100; i++) { col.Add(i); expected += i; } var map = from item in col select item.ToString(); var queryActor = map.AsActorQueryiable(); int sum = 0; foreach (var item in queryActor) { sum = sum + int.Parse(item, CultureInfo.InvariantCulture); } Assert.AreEqual(expected, sum); }
public void AddElementTest() { TestLauncherActor.Test(() => { var act = new EnumerableActor <string>(); act.Add("test"); }); }
public void GetEnumeratorTest() { fLauncher.SendAction(() => { var act = new EnumerableActor<string>(); act.Add("test1"); act.Add("test2"); var list = new List<string>(); foreach(var item in act) { list.Add(item); } Assert.AreEqual(2, list.Count); Assert.AreEqual(2, act.Count()); fLauncher.Finish(); }); Assert.IsTrue(fLauncher.Wait()); }
public void AddElementTest() { fLauncher.SendAction(() => { var act = new EnumerableActor<string>(); act.Add("test"); fLauncher.Finish(); }); Assert.IsTrue(fLauncher.Wait()); }
public void StressEnumeratorWithLinqTest() { TestLauncherActor.Test(() => { var act = new EnumerableActor <string>(); foreach (var item in Enumerable.Range(0, 100)) { act.Add(item.ToString()); } Assert.AreEqual(100, act.Count()); var query = from s in act where s.StartsWith("1") select s; Assert.AreEqual(11, query.Count()); Assert.IsTrue(query.Contains("11")); }); }
protected override void Process(string aT) { fActorReport.Add(aT); }