public void generateUpdateSqlString_ReturnsProperString_ForSingleElement() { DbStringBuilder builder = new DbStringBuilder(); builder.DbAppendix = "fx"; builder.Add("Value", 1); builder.AddWhere("Id", 1); string expected = "UPDATE fx.{0} SET Value = 1 WHERE Id = 1;"; Assert.AreEqual(expected, builder.GenerateUpdateSqlString()); }
public void afterAddingWhere_HasAddedConstraint_WhereAddedWithBooleanValue() { DbStringBuilder builder = new DbStringBuilder(); string key = "Id"; bool value = true; builder.AddWhere(key, value); string expected = "Id = 1"; Assert.IsTrue(builder.HasWhere(expected)); }
public void afterAddingWhere_HasAddedConstraint_WhereAddedWithDateValue() { DbStringBuilder builder = new DbStringBuilder(); string key = "Id"; DateTime value = new DateTime(2017, 4, 21); builder.AddWhere(key, value); string expected = "Id = '2017-04-21 00:00:00'"; Assert.IsTrue(builder.HasWhere(expected)); }
public void afterAddingWhere_HasAddedConstraint_WhereAddedWithDoubleValue() { DbStringBuilder builder = new DbStringBuilder(); string key = "Id"; double value = 1.234567; builder.AddWhere(key, value); string expected = "Id = 1.23457"; Assert.IsTrue(builder.HasWhere(expected)); }
public void afterAddingWhere_HasAddedConstraint_WhereAddedWithStringValue() { DbStringBuilder builder = new DbStringBuilder(); string key = "Id"; string value = "abc"; builder.AddWhere(key, value); string expected = "Id = 'abc'"; Assert.IsTrue(builder.HasWhere(expected)); }
public void generateUpdateSqlString_ReturnsProperString_ForSingleElementAndEmptyDbAppendix() { DbStringBuilder builder = new DbStringBuilder(); builder.DbAppendix = string.Empty; builder.Add("Value", 1); builder.AddWhere("Id", 1); string expected = "UPDATE {0} SET Value = 1 WHERE Id = 1;"; string actual = builder.GenerateUpdateSqlString(); Assert.AreEqual(expected, actual); }
public void generateUpdateSqlString_ReturnsProperString_ForManyElements() { 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.AddWhere("Id", 1); string expected = "UPDATE {0} SET Value = 1, Name = 'abc', Date = '2017-03-12 00:00:00', IsActive = 1 WHERE Id = 1;"; string actual = builder.GenerateUpdateSqlString(); Assert.AreEqual(expected, actual); }