Exemplo n.º 1
0
 protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, ColumnModification columnModification)
 {
     commandStringBuilder
         .Append(DelimitIdentifier(columnModification.ColumnName))
         .Append(" = ")
         .Append("provider_specific_identity()");
 }
 protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, ColumnModification columnModification)
 {
     commandStringBuilder
         .Append(DelimitIdentifier(columnModification.ColumnName))
         .Append(" = ")
         .Append("last_insert_rowid()");
 }
        protected override void ConfigureParameter(DbParameter parameter, ColumnModification columnModification)
        {
            Check.NotNull(parameter, nameof(parameter));
            Check.NotNull(columnModification, nameof(columnModification));

            parameter.Size = Size;

            base.ConfigureParameter(parameter, columnModification);
        }
        protected override void ConfigureParameter(DbParameter parameter, ColumnModification columnModification)
        {
            Check.NotNull(parameter, "parameter");
            Check.NotNull(columnModification, "columnModification");

            parameter.Size = _size;

            base.ConfigureParameter(parameter, columnModification);
        }
        protected override void ConfigureParameter(DbParameter parameter, ColumnModification columnModification)
        {
            Check.NotNull(parameter, nameof(parameter));
            Check.NotNull(columnModification, nameof(columnModification));

            // Note: Precision/scale should not be set for input parameters because this will cause truncation
            if (parameter.Direction == ParameterDirection.Output)
            {
                parameter.Scale = _scale;
                parameter.Precision = _precision;
            }

            base.ConfigureParameter(parameter, columnModification);
        }
        public void Get_Value_delegates_to_StateEntry()
        {
            var stateEntryMock = new Mock<StateEntry>();
            var columnModification = new ColumnModification(
                stateEntryMock.Object,
                new Mock<IProperty>().Object,
                parameterName: null,
                originalParameterName: null,
                isRead: false,
                isWrite: false,
                isKey: false,
                isCondition: false);

            var value = columnModification.Value;

            stateEntryMock.Verify(m => m[It.IsAny<IPropertyBase>()], Times.Once);
        }
        public void Get_OriginalValue_delegates_to_StateEntry_if_OriginalValues_if_unavailable()
        {
            var originalValuesMock = new Mock<Sidecar>();
            originalValuesMock.Setup(m => m.CanStoreValue(It.IsAny<IPropertyBase>())).Returns(false);
            var stateEntryMock = new Mock<StateEntry>();
            stateEntryMock.Setup(m => m.OriginalValues).Returns(originalValuesMock.Object);
            var columnModification = new ColumnModification(
                stateEntryMock.Object,
                new Mock<IProperty>().Object,
                parameterName: null,
                originalParameterName: null,
                isRead: false,
                isWrite: false,
                isKey: false,
                isCondition: false);

            var value = columnModification.OriginalValue;

            stateEntryMock.Verify(m => m[It.IsAny<IPropertyBase>()], Times.Once);
            originalValuesMock.Verify(m => m[It.IsAny<IPropertyBase>()], Times.Never);
        }
        public void Get_OriginalValue_delegates_to_Entry_if_OriginalValues_if_unavailable()
        {
            var internalEntryMock = CreateInternalEntryMock(Mock.Of<IProperty>());
            var originalValuesMock = new Mock<Sidecar>(internalEntryMock.Object);
            originalValuesMock.Setup(m => m.CanStoreValue(It.IsAny<IPropertyBase>())).Returns(false);
            internalEntryMock.Setup(m => m.OriginalValues).Returns(originalValuesMock.Object);
            var columnModification = new ColumnModification(
                internalEntryMock.Object,
                new Mock<IProperty>().Object,
                new Mock<IRelationalPropertyExtensions>().Object,
                new ParameterNameGenerator(),
                isRead: false,
                isWrite: false,
                isKey: false,
                isCondition: false);

            var value = columnModification.OriginalValue;

            internalEntryMock.Verify(m => m[It.IsAny<IPropertyBase>()], Times.Once);
            originalValuesMock.Verify(m => m[It.IsAny<IPropertyBase>()], Times.Never);
        }
        public void Parameters_return_set_values()
        {
            var columnModification = new ColumnModification(
                CreateInternalEntryMock(Mock.Of<IProperty>()).Object,
                new Mock<IProperty>().Object,
                new Mock<IRelationalPropertyExtensions>().Object,
                new ParameterNameGenerator(),
                isRead: true,
                isWrite: true,
                isKey: true,
                isCondition: true);

            Assert.Null(columnModification.ColumnName);
            Assert.True(columnModification.IsRead);
            Assert.True(columnModification.IsWrite);
            Assert.True(columnModification.IsKey);
            Assert.True(columnModification.IsCondition);
            Assert.Equal("@p0", columnModification.ParameterName);
            Assert.Equal("@p1", columnModification.OriginalParameterName);
            Assert.Equal("@p2", columnModification.OutputParameterName);
        }
        public void Set_Value_delegates_to_StateEntry()
        {
            var property = new Mock<IProperty>().Object;
            var stateEntryMock = new Mock<StateEntry>();
            var columnModification = new ColumnModification(
                stateEntryMock.Object,
                property,
                parameterName: null,
                originalParameterName: null,
                isRead: false,
                isWrite: false,
                isKey: false,
                isCondition: false);
            var value = new object();

            columnModification.Value = value;

            stateEntryMock.VerifySet(m => m[property] = It.IsAny<object>(), Times.Once);
        }
        public void Get_Value_delegates_to_Entry()
        {
            var internalEntryMock = CreateInternalEntryMock(Mock.Of<IProperty>());
            var columnModification = new ColumnModification(
                internalEntryMock.Object,
                new Mock<IProperty>().Object,
                new Mock<IRelationalPropertyExtensions>().Object,
                new ParameterNameGenerator(),
                isRead: false,
                isWrite: false,
                isKey: false,
                isCondition: false);

            var value = columnModification.Value;

            internalEntryMock.Verify(m => m[It.IsAny<IPropertyBase>()], Times.Once);
        }
        public void Set_Value_delegates_to_Entry()
        {
            var property = new Mock<IProperty>().Object;
            var internalEntryMock = CreateInternalEntryMock(property);
            var columnModification = new ColumnModification(
                internalEntryMock.Object,
                property,
                property.Relational(),
                new ParameterNameGenerator(),
                isRead: false,
                isWrite: false,
                isKey: false,
                isCondition: false);
            var value = new object();

            columnModification.Value = value;

            internalEntryMock.VerifySet(m => m[property] = It.IsAny<object>(), Times.Once);
        }
 protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, ColumnModification columnModification)
     => Check.NotNull(commandStringBuilder, nameof(commandStringBuilder))
         .Append(DelimitIdentifier(Check.NotNull(columnModification, nameof(columnModification)).ColumnName))
         .Append(" = ")
         .Append("scope_identity()");
Exemplo n.º 14
0
 protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, ColumnModification columnModification)
 {
     throw new NotImplementedException();
 }