Esempio n. 1
0
        public void Normal()
        {
            var obj  = Yueluo.Create();
            var sb   = new StringBuilder();
            var info = obj.V().ForEach((name, value) => sb.Append($"{name}:{value}{Environment.NewLine}"))
                       .GetDebugInfo();

            Console.WriteLine(info);
        }
Esempio n. 2
0
        public void Normal()
        {
            var obj = Yueluo.Create();
            var re  = obj.FormatToString();

            Console.WriteLine(re);
            var except = obj.FormatString();

            re.Should().Be(except);
        }
        public PropertyGetterTest()
        {
            _yueluo       = Yueluo.Create();
            _nameProperty = typeof(Yueluo).GetProperty(nameof(Yueluo.Name)) !;
            _ageProperty  = typeof(Yueluo).GetProperty(nameof(Yueluo.Age)) !;
            _nameFunc     = ValueGetter <Yueluo, string, string> .GetGetter(_nameProperty);

            _ = ValueGetter <Yueluo, int, int> .GetGetter(_ageProperty).Invoke(_yueluo);

            _ = ValueGetter <Yueluo> .GetGetter(_nameProperty).Invoke(_yueluo);
        }
Esempio n. 4
0
        public void NoExtendObj()
        {
            var obj     = Yueluo.Create();
            var sb      = new StringBuilder();
            var visitor = default(Yueluo).V()
                          .ForEach((name, value) => sb.Append($"{name}:{value}{Environment.NewLine}"))
                          .Cache();

            visitor.Run(obj);
            sb.ToString().Should().Be(obj.FormatString());
        }
Esempio n. 5
0
        public void NoExtendObj()
        {
            var obj    = Yueluo.Create();
            var sb     = new StringBuilder();
            var action = default(Yueluo).V()
                         .ForEach((name, value) => sb.Append($"{name}:{value}{Environment.NewLine}"))
                         .GetLambda();

            action.Invoke(obj);
            sb.ToString().Should().Be(obj.FormatString());
        }
Esempio n. 6
0
        public void NameAndValue()
        {
            var obj     = Yueluo.Create();
            var sb      = new StringBuilder();
            var context = obj.V()
                          .ForEach((name, value) => sb.Append($"{name}:{value}{Environment.NewLine}"));

            TestHelper.RunTest(context,
                               () =>
            {
                context.Run();
                var re     = sb.ToString();
                var except = obj.FormatString();
                re.Should().Be(except);
            });
        }
Esempio n. 7
0
        public void FullContextWithExt()
        {
            var obj     = Yueluo.Create();
            var sb      = new StringBuilder();
            var context = obj.V()
                          .WithExtendObject(sb)
                          .ForEach(c => c.ExtendObject.Append($"{c.Name}:{c.Value}{Environment.NewLine}"));

            TestHelper.RunTest(context,
                               () =>
            {
                context.Run();
                var re     = sb.ToString();
                var except = obj.FormatString();
                re.Should().Be(except);
            });
        }
Esempio n. 8
0
        public void NameAndValueWithExtWithType()
        {
            var obj     = Yueluo.Create();
            var sb      = new StringBuilder();
            var context = obj.V()
                          .WithExtendObject(sb)
                          .ForEach <Yueluo, StringBuilder, string>((name, value, s) =>
                                                                   s.Append($"{name}:{value}{Environment.NewLine}"));

            TestHelper.RunTest(context,
                               () =>
            {
                context.Run();
                var re     = sb.ToString();
                var except = obj.FormatOnlyString();
                re.Should().Be(except);
            });
        }