Ejemplo n.º 1
0
        public void WriterStringSelectManyTest01()
        {
            var m11   = new MonadPrimus.Writer <int>(1, "init1");
            var m12   = m11.SelectMany(x => new MonadPrimus.Writer <string>(x + "1", "next"));
            var res11 = m12.RunWriter();

            Assert.AreEqual("11", res11.Value);
            Assert.AreEqual("init1next", res11.State);
        }
Ejemplo n.º 2
0
        public void WriterSelectManyTest01()
        {
            var m11   = new MonadPrimus.Writer <string, int>(1, new string[] { "init1", "init2" });
            var m12   = m11.SelectMany(x => new MonadPrimus.Writer <string, string>(x + "1", new string[] { "next" }));
            var res11 = m12.RunWriter();

            Assert.AreEqual("11", res11.Value);
            Assert.AreEqual("init1", res11.State.ElementAt(0));
            Assert.AreEqual("init2", res11.State.ElementAt(1));
            Assert.AreEqual("next", res11.State.ElementAt(2));
            Assert.AreEqual(3, res11.State.Count());
        }
Ejemplo n.º 3
0
        public void WriterStringMonadRule2Test()
        {
            var m00   = new MonadPrimus.Writer <int>(1, "init1");
            var m11   = m00.SelectMany(MonadPrimus.ToWriter <int>);
            var m12   = m00;
            var res11 = m11.RunWriter();
            var res12 = m12.RunWriter();

            Assert.AreEqual(1, res11.Value);
            Assert.AreEqual("init1", res11.State);
            Assert.AreEqual(1, res12.Value);
            Assert.AreEqual("init1", res12.State);
        }
Ejemplo n.º 4
0
        public void WriterMonadRule2Test()
        {
            var m00   = new MonadPrimus.Writer <string, int>(1, new string[] { "init1", "init2" });
            var m11   = m00.SelectMany(MonadPrimus.ToWriter <string, int>);
            var m12   = m00;
            var res11 = m11.RunWriter();
            var res12 = m12.RunWriter();

            Assert.AreEqual(1, res11.Value);
            Assert.AreEqual("init1", res11.State.ElementAt(0));
            Assert.AreEqual("init2", res11.State.ElementAt(1));
            Assert.AreEqual(2, res11.State.Count());
            Assert.AreEqual(1, res12.Value);
            Assert.AreEqual("init1", res12.State.ElementAt(0));
            Assert.AreEqual("init2", res12.State.ElementAt(1));
            Assert.AreEqual(2, res12.State.Count());
        }