コード例 #1
0
        public void UnlessExtensionTest()
        {
            var input = new Number(1);
            var result = input.Unless(x => x.Value == 1);
            Assert.IsNull(result);

            result = input.Unless(x => x.Value > 1);
            Assert.AreSame(input, result);
        }
コード例 #2
0
        public void ReturnExtensionTest()
        {
            var defaultValue = "Preceding expression returned NULL, default is returned.";

            var input = new Number(1);
            var result = input.With(x => x.Value == 1 ? x.ToString() : null).Return(x => x, defaultValue);
            Assert.AreEqual(result, "1");

            result = input.With(x => x.Value > 1 ? x.ToString() : null).Return(x => x, defaultValue);
            Assert.AreEqual(result, defaultValue);
        }
コード例 #3
0
        public void WithExtensionTest()
        {
            var input = new Number(1);

            var result = input.With(x => x.ToString()).Return(x => x, null);

            Assert.AreEqual(result, "1");

            var input2 = new Number(1);

            var result2 = input.With(x => new Number{Value = x.Value + 1}).Return(x => x, null);

            Assert.IsTrue(result2 is Number);
            Assert.AreEqual(result2.Value, 2);
        }
コード例 #4
0
        public void DoExtensionTest()
        {
            var input = new Number(1);

            var result = input.Do((x) => {x.Value++; });

            Assert.AreEqual(input.Value, 2);
        }