public void generateInsertSqlString_ReturnsProperString_ForManyElementsAndTimestamp() { DbStringBuilder builder = new DbStringBuilder(); builder.DbAppendix = "fx"; builder.Add("Value", 1); builder.Add("Name", "abc"); builder.Add("Date", new DateTime(2017, 3, 12)); builder.Add("IsActive", true); builder.AddTimestamp(); string expected = "INSERT INTO fx.{0}(Value, Name, Date, IsActive, Timestamp) VALUES(1, 'abc', '2017-03-12 00:00:00', 1, NOW());"; Assert.AreEqual(expected, builder.GenerateInsertSqlString()); }
public void generateUpdateSqlString_ReturnsProperString_ForManyElementsAndTimestamp() { DbStringBuilder builder = new DbStringBuilder(); builder.Add("Value", 1); builder.Add("Name", "abc"); builder.Add("Date", new DateTime(2017, 3, 12)); builder.Add("IsActive", true); builder.AddTimestamp(); builder.AddWhere("Id", 1); string expected = "UPDATE {0} SET Value = 1, Name = 'abc', Date = '2017-03-12 00:00:00', IsActive = 1, Timestamp = NOW() WHERE Id = 1;"; string actual = builder.GenerateUpdateSqlString(); Assert.AreEqual(expected, actual); }