public void WriterSelectManyAndLogNumberLinqQuerySyntax() { var m1 = WriterString.Return(3); var m2 = WriterString.Return(5); var mr = from n1 in m1 from _ in LogNumber(n1) from n2 in m2 from __ in LogNumber(n2) select n1 *n2; var actual = mr.RunWriter; Assert.That(actual.Item1, Is.EqualTo(3 * 5)); Assert.That(actual.Item2.List, Is.EqualTo(new[] { "Got number 3", "Got number 5" })); }
public void WriterSelectManyAndTellLinqQuerySyntax() { var m1 = WriterString.Return("Hello"); var m2 = WriterString.Return(2); var mr = from s in m1 from _ in TellHelper(string.Format("s = {0}", s)) from n in m2 from __ in TellHelper(string.Format("n = {0}", n)) select string.Concat(Enumerable.Repeat(s, n)); var actual = mr.RunWriter; Assert.That(actual.Item1, Is.EqualTo("HelloHello")); Assert.That(actual.Item2.List, Is.EqualTo(new[] { "s = Hello", "n = 2" })); }
private static Writer <ListMonoid <string>, string, Unit> TellHelper(string s) { return(WriterString.Tell(new ListMonoid <string>(s))); }