Ejemplo n.º 1
0
        public void AllFormattersTest()
        {
            var obj = new List <object>
            {
                "123",
                123,
                (ushort)2,
                new HashSet <int>
                {
                    1,
                    2,
                    3,
                    4
                },
                new Dictionary <string, string>
                {
                    { "at Radolyn we take", "our jobs very seriously" },
                    { "yes", null } // haha, suppress null warning with '!', wtf
                },
                null,
                null,
                new List <ushort>
                {
                    120,
                    1
                }.AsQueryable(),
                new ArgumentException("oh it works!")
            };

            var res = FormattersStorage.GetCustomFormatterResult(obj);

            Assert.False(string.IsNullOrWhiteSpace(res));
        }
Ejemplo n.º 2
0
        public void GetCustomFormatterResultTest()
        {
            FormattersStorage.AddDefault();
            FormattersStorage.AddFormatter <EnumerableFormatter>();

            FormattersStorage.MaxRecursion = 2;

            var res = FormattersStorage.GetCustomFormatterResult(new List <object>
            {
                "sadasdsda",
                123,
                new List <int>
                {
                    1,
                    2
                }
            });

            Assert.True(FormattersStorage.RegisteredFormatters.Any());
            Assert.False(string.IsNullOrWhiteSpace(res));
        }
Ejemplo n.º 3
0
        public void AssertConsoleProxies()
        {
            // actually, we can't test such a things because we can't allocate real console even for a 1 test
            // so just check the output of this test to see exceptions

            var properties = typeof(Console).GetProperties();

            foreach (var property in properties)
            {
                try
                {
                    var val = property.GetValue(null);

                    if (property.CanWrite)
                    {
                        property.GetValue(val);
                    }
                }
                catch (Exception ex)
                {
                    Output.WriteLine(FormattersStorage.GetCustomFormatterResult(ex) + Environment.NewLine.Repeat(2));
                }
            }
        }