public void ListFormatedCorrectlyWithoutAttributes() { Formater format = new Formater(); List <Tag> ListaTags = new List <Tag>(); ListaTags.Add(new Tag("personas")); ListaTags.Add(new Tag("pedro")); List <string> listaFormated = format.Format(ListaTags); List <string> ListaExpected = new List <string> { "personas", "pedro" }; for (int i = 0; i < ListaExpected.Count; i++) { string elemento = listaFormated[i]; string elementoExpected = ListaExpected[i]; Assert.Equal(elemento, elementoExpected); } }
public void ListFormatedCorrectly() { Formater format = new Formater(); Dictionary <string, Attribute> attributeList = new Dictionary <string, Attribute>(); Attribute attribute = new Attribute("pedro", "15"); Attribute attribute2 = new Attribute("marcos", "13"); List <Tag> ListaTags = new List <Tag>(); attributeList.Add(attribute.Key, attribute); attributeList.Add(attribute2.Key, attribute2); ListaTags.Add(new Tag("personas", attributeList)); List <string> listaFormated = format.Format(ListaTags); List <string> ListaExpected = new List <string> { "personas", "pedro=15", "marcos=13" }; for (int i = 0; i < ListaExpected.Count; i++) { string elemento = listaFormated[i]; string elementoExpected = ListaExpected[i]; Assert.Equal(elemento, elementoExpected); } }
void AddParameters(IDbCommand cmd, LogEntry entry) { var dbParam = cmd.CreateParameter(); dbParam.ParameterName = "@Category"; dbParam.DbType = DbType.String; dbParam.Value = entry.Category ?? string.Empty; cmd.Parameters.Add(dbParam); dbParam = cmd.CreateParameter(); dbParam.ParameterName = "@Details"; dbParam.DbType = DbType.String; dbParam.Value = entry.DetailsObject == null?string.Empty:(Formater == null?entry.DetailsObject.ToString():Formater.Format(entry.DetailsObject)); cmd.Parameters.Add(dbParam); dbParam = cmd.CreateParameter(); dbParam.ParameterName = "@Host"; dbParam.DbType = DbType.String; dbParam.Value = entry.Host ?? string.Empty; cmd.Parameters.Add(dbParam); dbParam = cmd.CreateParameter(); dbParam.ParameterName = "@LogLevel"; dbParam.DbType = DbType.Int32; dbParam.Value = (int)entry.LogLevel; cmd.Parameters.Add(dbParam); dbParam = cmd.CreateParameter(); dbParam.ParameterName = "@LogTime"; dbParam.DbType = DbType.DateTime; dbParam.Value = entry.LogTime; cmd.Parameters.Add(dbParam); dbParam = cmd.CreateParameter(); dbParam.ParameterName = "@Message"; dbParam.DbType = DbType.String; dbParam.Value = entry.Message == null?string.Empty:(entry.MessageReplacements == null?entry.Message:string.Format(entry.Message, entry.MessageReplacements)); cmd.Parameters.Add(dbParam); dbParam = cmd.CreateParameter(); dbParam.ParameterName = "@TraceId"; dbParam.DbType = DbType.String; dbParam.Value = entry.TraceId ?? string.Empty; cmd.Parameters.Add(dbParam); }