Example #1
0
        public void NoType()
        {
            var kvp = Array.Empty <KeyValuePair <string, object?> >();

            var s = new LogStateHolder();

            TestCollection(kvp, s);
            Assert.Equal(string.Empty, LogStateHolder.Format(new LogStateHolder(), null));
        }
Example #2
0
        public void OneType()
        {
            var kvp = new KeyValuePair <string, object?>[]
            {
                new KeyValuePair <string, object?>("name1", 1),
            };

            Func <LogStateHolder <int>, Exception?, string> f = (_, _) => string.Empty;
            var s = new LogStateHolder <int>(f, "name1", 1);

            TestCollection(kvp, s);
            Assert.Equal(kvp[0].Value, s.Value);
        }
Example #3
0
        public void TwoTypes()
        {
            var kvp = new KeyValuePair <string, object?>[]
            {
                new KeyValuePair <string, object?>("name1", 1),
                new KeyValuePair <string, object?>("name2", 2),
            };

            Func <LogStateHolder <int, int>, Exception?, string> f = (_, _) => string.Empty;
            var s = new LogStateHolder <int, int>(f, new[] { "name1", "name2" }, 1, 2);

            TestCollection(kvp, s);
            Assert.Equal(kvp[0].Value, s.Value1);
            Assert.Equal(kvp[1].Value, s.Value2);
        }
Example #4
0
        public void FiveTypes()
        {
            var kvp = new KeyValuePair <string, object?>[]
            {
                new KeyValuePair <string, object?>("name1", 1),
                new KeyValuePair <string, object?>("name2", 2),
                new KeyValuePair <string, object?>("name3", 3),
                new KeyValuePair <string, object?>("name4", 4),
                new KeyValuePair <string, object?>("name5", 5),
            };

            Func <LogStateHolder <int, int, int, int, int>, Exception?, string> f = (_, _) => string.Empty;
            var s = new LogStateHolder <int, int, int, int, int>(f, new[] { "name1", "name2", "name3", "name4", "name5" }, 1, 2, 3, 4, 5);

            TestCollection(kvp, s);
            Assert.Equal(kvp[0].Value, s.Value1);
            Assert.Equal(kvp[1].Value, s.Value2);
            Assert.Equal(kvp[2].Value, s.Value3);
            Assert.Equal(kvp[3].Value, s.Value4);
            Assert.Equal(kvp[4].Value, s.Value5);
        }