Пример #1
0
        public void AddParameters_OneValue()
        {
            var specification = new ComparedColumnsSpecification(new[] { new ColumnValue(_column1, _value1) });

            _sqlDialectStub.Stub(stub => stub.GetParameterName("First")).Return("pFirst");

            var parameterStrictMock = MockRepository.GenerateStrictMock <IDbDataParameter> ();

            parameterStrictMock.Expect(mock => mock.ParameterName = "pFirst");
            parameterStrictMock.Replay();

            _parametersCollectionMock.Expect(mock => mock.Add(parameterStrictMock)).Return(0);
            _parametersCollectionMock.Replay();

            _storageTypeInformationMock1
            .Expect(mock => mock.CreateDataParameter(_commandStub, _value1))
            .Return(parameterStrictMock);
            _storageTypeInformationMock1.Replay();

            specification.AddParameters(_commandStub, _sqlDialectStub);

            _parametersCollectionMock.VerifyAllExpectations();
            parameterStrictMock.VerifyAllExpectations();
            _storageTypeInformationMock1.VerifyAllExpectations();
        }
Пример #2
0
        public void AppendComparisons_OneValue()
        {
            var specification = new ComparedColumnsSpecification(new[] { new ColumnValue(_column1, _value1) });

            _statement.Append("<existingtext>");

            _sqlDialectStub.Stub(stub => stub.GetParameterName("First")).Return("pFirst");
            _sqlDialectStub.Stub(mock => mock.DelimitIdentifier("First")).Return("[First]");

            specification.AppendComparisons(_statement, _commandStub, _sqlDialectStub);

            _parametersCollectionMock.VerifyAllExpectations();
            _storageTypeInformationMock1.VerifyAllExpectations();

            Assert.That(_statement.ToString(), Is.EqualTo("<existingtext>[First] = pFirst"));
        }
Пример #3
0
        public void AppendComparisons_MultipleValues_EmptyParameterDictionary()
        {
            var columnValue1  = new ColumnValue(_column1, _value1);
            var columnValue2  = new ColumnValue(_column2, _value2);
            var specification = new ComparedColumnsSpecification(new[] { columnValue1, columnValue2 });

            _statement.Append("<existingtext>");

            _sqlDialectStub.Stub(stub => stub.GetParameterName("First")).Return("pFirst");
            _sqlDialectStub.Stub(stub => stub.GetParameterName("Second")).Return("pSecond");

            _sqlDialectStub.Stub(mock => mock.DelimitIdentifier("First")).Return("[First]");
            _sqlDialectStub.Stub(mock => mock.DelimitIdentifier("Second")).Return("[Second]");

            specification.AppendComparisons(_statement, _commandStub, _sqlDialectStub);

            Assert.That(_statement.ToString(), Is.EqualTo("<existingtext>[First] = pFirst AND [Second] = pSecond"));
        }
Пример #4
0
        public void Initialization_NonEmpty()
        {
            var specification = new ComparedColumnsSpecification(new[] { new ColumnValue(_column1, _value1) });

            Assert.That(specification.ComparedColumnValues, Is.EqualTo(new[] { new ColumnValue(_column1, _value1) }));
        }