Пример #1
0
        public void CallingWithDefaultSetsDefaultValue()
        {
            var contextMock = new Mock <IMigrationContext>();

            var columnMock = new Mock <ColumnDefinition>();

            var expressionMock = new Mock <AlterTableExpression>();

            var builder = new AlterTableExpressionBuilder(expressionMock.Object, contextMock.Object);

            builder.CurrentColumn = columnMock.Object;
            builder.WithDefault(SystemMethods.CurrentDateTime);

            columnMock.VerifySet(c => c.DefaultValue = SystemMethods.CurrentDateTime);
        }
Пример #2
0
        public void CallingWithDefaultOnAlterColumnAddsDefaultConstraintExpression()
        {
            var expressions = new List <IMigrationExpression>();
            var contextMock = new Mock <IMigrationContext>();

            contextMock.Setup(x => x.Expressions).Returns(expressions);

            var columnMock = new Mock <ColumnDefinition>();

            columnMock.Setup(x => x.ModificationType).Returns(ColumnModificationType.Alter);

            var expressionMock = new Mock <AlterTableExpression>();

            var builder = new AlterTableExpressionBuilder(expressionMock.Object, contextMock.Object);

            builder.CurrentColumn = columnMock.Object;
            builder.WithDefault(SystemMethods.CurrentDateTime);

            Assert.That(expressions.Count(), Is.EqualTo(1));
        }
        public void CallingWithDefaultSetsDefaultValue()
        {
            var contextMock = new Mock<IMigrationContext>();

            var columnMock = new Mock<ColumnDefinition>();

            var expressionMock = new Mock<AlterTableExpression>();

            var builder = new AlterTableExpressionBuilder(expressionMock.Object, contextMock.Object);
            builder.CurrentColumn = columnMock.Object;
            builder.WithDefault(SystemMethods.CurrentDateTime);

            columnMock.VerifySet(c => c.DefaultValue = SystemMethods.CurrentDateTime);
        }
        public void CallingWithDefaultOnNewColumnDoesNotAddDefaultConstraintExpression()
        {
            var expressions = new List<IMigrationExpression>();
            var contextMock = new Mock<IMigrationContext>();
            contextMock.Setup(x => x.Expressions).Returns(expressions);

            var columnMock = new Mock<ColumnDefinition>();
            columnMock.Setup(x => x.ModificationType).Returns(ColumnModificationType.Create);

            var expressionMock = new Mock<AlterTableExpression>();

            var builder = new AlterTableExpressionBuilder(expressionMock.Object, contextMock.Object);
            builder.CurrentColumn = columnMock.Object;
            builder.WithDefault(SystemMethods.CurrentDateTime);

            Assert.That(expressions.Count(), Is.EqualTo(0));
        }