Exemplo n.º 1
0
        public void should_convert_fieldnames_to_pascalcase_recursively_through_lists()
        {
            const string valueToCheckFor = "valuetocheckfor";

            var obj = new Dictionary <string, object> {
                { "Base", new[] { new Dictionary <string, object> {
                                      { "field_Name", valueToCheckFor }
                                  } } }
            };

            var output = new List <ProcessedLogEvent>();
            var logger = new Logger(logEvents => logEvents
                                    .Select(BasicFormatting.Process)
                                    .Select(FieldNameFormatting.ToPascalCase())
                                    .Subscribe(log => output.Add(log))
                                    );

            logger.Info(obj);

            var array  = (IEnumerable <object>)output[0].Content.First().Value;
            var subObj = (Dictionary <string, object>)array.First();
            var field  = subObj.First();

            Assert.Equal("FieldName", field.Key);
            Assert.Equal(valueToCheckFor, field.Value);
        }
Exemplo n.º 2
0
        public void should_convert_fieldnames_to_pascalcase(string originalFieldName, string finalFieldName)
        {
            const string valueToCheckFor = "valuetocheckfor";

            var obj = new Dictionary <string, object> {
                { originalFieldName, valueToCheckFor }
            };

            var output = new List <ProcessedLogEvent>();
            var logger = new Logger(logEvents => logEvents
                                    .Select(BasicFormatting.Process)
                                    .Select(FieldNameFormatting.ToPascalCase())
                                    .Subscribe(log => output.Add(log))
                                    );

            logger.Info(obj);

            var field = output[0].Content.First();

            Assert.Equal(finalFieldName, field.Key);
            Assert.Equal(valueToCheckFor, field.Value);
        }