Exemple #1
0
        public void UseValueGenerator()
        {
            TableInfo tableInfo = CreateTableInfoFromDto <ConverterDto>();

            tableInfo.Columns.Single(c => c.Name == nameof(ConverterDto.Id)).ValueGenerator = new AutoIncrementValueGenerator();
            ColumnInfo idColumn = tableInfo.Columns.Single(col => col.Name == nameof(ConverterDto.Id));

            CommandGenerator <ConverterDto> commandGenerator = CreateCommandGenerator <ConverterDto>(tableInfo);

            var dto = new ConverterDto()
            {
                Id = 1, Name = null
            };

            commandGenerator.SetColumnValueFromValueGenerator(idColumn, dto, ValueGenerated.Never);
            var convertedValue = commandGenerator.GetColumnValue(idColumn, dto, ValueGenerated.Never);

            convertedValue.Should().Be(AutoIncrementValueGenerator.GeneratedValue);
        }