Let's look at my json string structure.
So there are 7 loggers, let's expand the nodes for the details.
{
"root_logger" : "MyFailoverLogger",
"loggers": [
{
"logger_name": "MyFileLogger",
"logger_type": "MyCompany.Loggers.FileSystemLogger",
"layout": "${message}|${exception}",
"stack_trace": {
"error": true,
"fatal": false
},
"file_path_pattern" : "\\\\corporate.MyCompany.com\\data\\recordings\\logs\\YYYY\\MM\\DD",
"file_name_pattern" : "app.{MMDDhhmm}.log",
"rollover_after_n_hours" : 5,
"rollover_after_n_megabytes": 5,
"level" : {
"min_level" : "INFO",
"max_level" : "DEBUG"
}
},
{
"logger_name" : "MyDbLogger",
"logger_type" : "MyCompany.Loggers.DatabaseLogger",
"connection_string" : "",
"target_table" : "",
"command_timeout_milliseconds" : 100,
"layout" : "${message}",
"level" : {
"min_level" : "INFO",
"max_level" : "DEBUG"
}
},
I am not sure how to test it but I have the primary code here.
[Theory]
[InlineData("MyFileLogger")]
[InlineData("MyDbLogger")]
[InlineData("MyDbLogger2")]
[InlineData("MyConsoleLogger")]
[InlineData("MyNullLogger")]
[InlineData("MyMultiplexingLogger")]
[InlineData("MyFailoverLogger")]
public void JSONConfigurationFileParser_Should_Return_A_Logger_Given_A_Name(string expextedLoggerName)
{
// ARRANGE
var currentFilePath = Environment.CurrentDirectory + @"\MyCompanyConfiguration.json";
var jsonString = File.ReadAllText(currentFilePath);
var jsonConfigurationFileParser = new JSONConfigurationFileParser(jsonString);
// ACT
var actualLoggers = jsonConfigurationFileParser.DeserializeLogger();
// ASSERT
}
The actualLoggers does return all 7 loggers. My question is that I am not sure how to test it properly. Should I use InlineData or something else. I left the assert part empty now.
Aucun commentaire:
Enregistrer un commentaire