Beispiel #1
0
        /// <inheritdoc />
        public IConditionBuilder WithCondition(string leftConditionTable, string leftConditionColumn, EqualityOperators equalityOperator, string rightConditionTable, string rightConditionColumn)
        {
            var columnConditionModel = new ColumnConditionModel(leftConditionTable, leftConditionColumn, equalityOperator, rightConditionTable, rightConditionColumn);

            _buildConditions.Add(_conditionNumber++, columnConditionModel);

            return(this);
        }
        public void Constructor()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var selectColumn = new ColumnConditionModel("SourceTable", "SourceColumn", EqualityOperators.Equals, "CompareTable", "CompareColumn");

            //---------------Test Result -----------------------
            Assert.IsNotNull(selectColumn);
        }
        public void ToString_GivenConditionValues_ShouldReturnExpectedStatement(string sourceTable, string sourceColumn,
                                                                                EqualityOperators equalityOperator,
                                                                                string compareTable, string compareColumn, string expectedStatement)
        {
            //---------------Set up test pack-------------------
            var conditionColumn = new ColumnConditionModel(sourceTable, sourceColumn, equalityOperator, compareTable, compareColumn)
            {
                DatabaseProvider = new SqlServerDatabaseProvider()
            };
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var selectStatement = conditionColumn.ToString();

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedStatement, selectStatement);
        }
        public void Equals_GivenDifferentConditionData_ShouldReturnTrue(string sourceTable, string sourceColumn,
                                                                        EqualityOperators equalityOperator,
                                                                        string compareTable, string compareColumn)
        {
            //---------------Set up test pack-------------------
            var conditionModel = new ColumnConditionModel(sourceTable, sourceColumn, equalityOperator, compareTable, compareColumn)
            {
                DatabaseProvider = new SqlServerDatabaseProvider()
            };
            var compareCondition = new ColumnConditionModel("unknownTable", "illegalColumn", EqualityOperators.StartsWith, "UnknownCompareTable", "UnknownCompareColumn")
            {
                DatabaseProvider = new SqlServerDatabaseProvider()
            };
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var equalResult = conditionModel.Equals(compareCondition);

            //---------------Test Result -----------------------
            Assert.IsFalse(equalResult);
        }
        public void Equals_GivenSameConditionData_ShouldReturnTrue(string sourceTable, string sourceColumn,
                                                                   EqualityOperators equalityOperator,
                                                                   string compareTable, string compareColumn)
        {
            //---------------Set up test pack-------------------
            var conditionModel = new ColumnConditionModel(sourceTable, sourceColumn, equalityOperator, compareTable, compareColumn)
            {
                DatabaseProvider = new SqlServerDatabaseProvider()
            };
            var compareCondition = new ColumnConditionModel(sourceTable, sourceColumn, equalityOperator, compareTable, compareColumn)
            {
                DatabaseProvider = new SqlServerDatabaseProvider()
            };
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var equalResult = conditionModel.Equals(compareCondition);

            //---------------Test Result -----------------------
            Assert.IsTrue(equalResult);
        }