public void ThrowExceptionIfTheIdentityFieldIsNotThePrimaryField() { // Setup var statementBuilder = new SqlDbStatementBuilder(); var queryBuilder = new QueryBuilder <ThrowExceptionIfTheIdentityFieldIsNotThePrimaryFieldClass>(); var queryGroup = (QueryGroup)null; // Act/Assert Assert.Throws <InvalidOperationException>(() => statementBuilder.CreateUpdate(queryBuilder, queryGroup)); }
public void TestWithFieldMapping() { // Setup var statementBuilder = new SqlDbStatementBuilder(); var queryBuilder = new QueryBuilder <TestWithFieldMappingClass>(); var queryGroup = (QueryGroup)null; // Act var actual = statementBuilder.CreateUpdate(queryBuilder, queryGroup); var expected = $"" + $"UPDATE [TestWithFieldMappingClass] " + $"SET [Field1] = @Field1, [Field2] = @Field2, [Field4] = @Field4 ;"; // Assert Assert.AreEqual(expected, actual); }
public void TestWithExpression() { // Setup var statementBuilder = new SqlDbStatementBuilder(); var queryBuilder = new QueryBuilder <TestWithExpressionClass>(); var queryGroup = QueryGroup.Parse(new { Field1 = 1, Field4 = new { Operation = Operation.GreaterThan, Value = 2 } }); // Act var actual = statementBuilder.CreateUpdate(queryBuilder, queryGroup); var expected = $"" + $"UPDATE [TestWithExpressionClass] " + $"SET [Field2] = @Field2, [Field3] = @Field3 " + $"WHERE ([Field1] = @_Field1 AND [Field4] > @_Field4) ;"; // Assert Assert.AreEqual(expected, actual); }