public void NullPropertyProgmaticConfig() { AdoNetAppenderParameter productIdParam = new AdoNetAppenderParameter(); productIdParam.ParameterName = "@productId"; productIdParam.DbType = DbType.String; productIdParam.Size = 50; RawPropertyLayout rawPropertyLayout = new RawPropertyLayout(); rawPropertyLayout.Key = "ProductId"; productIdParam.Layout = rawPropertyLayout; AdoNetAppender appender = new AdoNetAppender(); appender.ConnectionType = typeof(Log4NetConnection).FullName; appender.BufferSize = -1; appender.CommandText = "INSERT INTO Log ([productId]) VALUES (@productId)"; appender.AddParameter(productIdParam); appender.ActivateOptions(); ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString()); BasicConfigurator.Configure(rep, appender); ILog log = LogManager.GetLogger(rep.Name, "NullPropertyProgmaticConfig"); log.Debug("Message"); IDbCommand command = Log4NetCommand.MostRecentInstance; IDbDataParameter param = (IDbDataParameter)command.Parameters["@productId"]; Assert.AreNotEqual(SystemInfo.NullText, param.Value); Assert.AreEqual(DBNull.Value, param.Value); }
/// <summary> /// /// </summary> /// <param name="parameterName"></param> /// <param name="dbType"></param> /// <param name="layout"></param> public DBAppenderParameter(string parameterName, DbType dbType, string layout) { this.DbType = dbType; this.ParameterName = parameterName; RawPropertyLayout rawLayout = new RawPropertyLayout(); rawLayout.Key = layout; this.Layout = rawLayout; }
public void ConfigureLayout_WithAttribute_ShouldSetKey() { // Arrange var attribute = new RawPropertyLayoutAttribute("test"); var layout = new RawPropertyLayout(); // Act sut.ConfigureLayout(layout, attribute); // Assert Assert.AreEqual(attribute.Key, layout.Key); }