Exemplo n.º 1
0
        public void AlternateSerializeWayByName()
        {
            var config = new PrintingConfig <Person>();

            config.Select(x => x.Width).SetSerializeWay(value => "Secret number");
            config.Select(x => x.Height).SetSerializeWay(value => $"Around {Math.Round(value, 0)}");

            var printed = config.PrintToString(person);

            AssertPrinting(printed, new[] { "Secret number", "Around 33" }, new[] { "99" });
        }
Exemplo n.º 2
0
        public void AlternateSerializeWayByType()
        {
            var config = new PrintingConfig <Person>();

            config.Select <int>().SetSerializeWay(value => $"This is int: {value}");

            var printed = config.PrintToString(person);

            AssertPrinting(printed, new[] { "This is int:" }, new string[0]);
        }
Exemplo n.º 3
0
        public void StringMustBeCropped()
        {
            var config = new PrintingConfig <Person>();

            config.Select <string>().CropTo(2);

            var printed = config.PrintToString(person);

            AssertPrinting(printed, new[] { "Je" }, new[] { "ff" });
        }
Exemplo n.º 4
0
        public void SpecificCulture()
        {
            var config = new PrintingConfig <Person>();

            config.Select <double>().SetCulture(specificCulture);

            person.Height = double.NaN;
            var printed = config.PrintToString(person);

            AssertPrinting(printed, new[] { "https://habr.com/ru/news/t/526412/" }, new string[0]);
        }