public void ModificationCommand_initialized_correctly_for_added_entities_with_client_generated_key() { var stateEntry = CreateStateEntry(EntityState.Added); var command = new ModificationCommand("T1", null, new ParameterNameGenerator()); command.AddStateEntry(stateEntry); Assert.Equal("T1", command.TableName); Assert.Equal(EntityState.Added, command.EntityState); Assert.Equal(2, command.ColumnModifications.Count); var columnMod = command.ColumnModifications[0]; Assert.Equal("Col1", columnMod.ColumnName); Assert.Same(stateEntry, columnMod.StateEntry); Assert.Equal("Id", columnMod.Property.Name); Assert.False(columnMod.IsCondition); Assert.True(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.True(columnMod.IsWrite); columnMod = command.ColumnModifications[1]; Assert.Equal("Col2", columnMod.ColumnName); Assert.Same(stateEntry, columnMod.StateEntry); Assert.Equal("Name", columnMod.Property.Name); Assert.False(columnMod.IsCondition); Assert.False(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.True(columnMod.IsWrite); }
public override void AppendUpdateOperation( StringBuilder commandStringBuilder, ModificationCommand command) { Check.NotNull(commandStringBuilder, nameof(commandStringBuilder)); Check.NotNull(command, nameof(command)); var tableName = command.TableName; var schemaName = command.SchemaName; var operations = command.ColumnModifications; var writeOperations = operations.Where(o => o.IsWrite).ToArray(); var conditionOperations = operations.Where(o => o.IsCondition).ToArray(); var readOperations = operations.Where(o => o.IsRead).ToArray(); AppendUpdateCommandHeader(commandStringBuilder, tableName, schemaName, writeOperations); if (readOperations.Length > 0) { AppendOutputClause(commandStringBuilder, readOperations); } AppendWhereClause(commandStringBuilder, conditionOperations); commandStringBuilder.Append(BatchCommandSeparator).AppendLine(); if (readOperations.Length == 0) { AppendSelectAffectedCountCommand(commandStringBuilder, tableName, schemaName); } }
public void ModificationCommand_initialized_correctly_for_added_entities_with_non_temp_generated_key() { var entry = Createentry(EntityState.Added, generateKeyValues: true); entry.MarkAsTemporary(entry.EntityType.GetPrimaryKey().Properties[0], isTemporary: false); var command = new ModificationCommand("T1", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); command.AddEntry(entry); Assert.Equal("T1", command.TableName); Assert.Null(command.SchemaName); Assert.Equal(EntityState.Added, command.EntityState); Assert.Equal(2, command.ColumnModifications.Count); var columnMod = command.ColumnModifications[0]; Assert.Equal("Col1", columnMod.ColumnName); Assert.Same(entry, columnMod.Entry); Assert.Equal("Id", columnMod.Property.Name); Assert.False(columnMod.IsCondition); Assert.True(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.True(columnMod.IsWrite); Assert.Null(columnMod.BoxedValueReader); columnMod = command.ColumnModifications[1]; Assert.Equal("Col2", columnMod.ColumnName); Assert.Same(entry, columnMod.Entry); Assert.Equal("Name", columnMod.Property.Name); Assert.False(columnMod.IsCondition); Assert.False(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.True(columnMod.IsWrite); Assert.Null(columnMod.BoxedValueReader); }
public override void AppendInsertOperation( StringBuilder commandStringBuilder, ModificationCommand command) { Check.NotNull(command, nameof(command)); AppendBulkInsertOperation(commandStringBuilder, new[] { command }); }
protected override bool CanAddCommand(ModificationCommand modificationCommand) { if (_maxBatchSize <= ModificationCommands.Count) { return false; } var additionalParameterCount = CountParameters(modificationCommand); if (_parameterCount + additionalParameterCount >= MaxParameterCount) { return false; } _parameterCount += additionalParameterCount; return true; }
private int CountParameters(ModificationCommand modificationCommand) { var parameterCount = 0; foreach (var columnModification in modificationCommand.ColumnModifications) { if (columnModification.ParameterName != null) { parameterCount++; } if (columnModification.OriginalParameterName != null) { parameterCount++; } } return parameterCount; }
public void RequiresResultPropagation_false_for_Delete_operation() { var entry = Createentry( EntityState.Deleted, generateKeyValues: true, computeNonKeyValue: true); var command = new ModificationCommand("T1", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); command.AddEntry(entry); Assert.False(command.RequiresResultPropagation); }
public void Compare_returns_0_only_for_commands_that_are_equal() { var model = new Entity.Metadata.Model(); var entityType = model.AddEntityType(typeof(object)); var optionsBuilder = new DbContextOptionsBuilder() .UseModel(model); optionsBuilder.UseInMemoryStore(persist: false); var contextServices = ((IAccessor<IServiceProvider>)new DbContext(optionsBuilder.Options)).Service; var stateManager = contextServices.GetRequiredService<IStateManager>(); var key = entityType.GetOrAddProperty("Id", typeof(int), shadowProperty: true); entityType.GetOrSetPrimaryKey(key); var entry1 = stateManager.GetOrCreateEntry(new object()); entry1[key] = 1; entry1.SetEntityState(EntityState.Added); var modificationCommandAdded = new ModificationCommand("A", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); modificationCommandAdded.AddEntry(entry1); var entry2 = stateManager.GetOrCreateEntry(new object()); entry2[key] = 2; entry2.SetEntityState(EntityState.Modified); var modificationCommandModified = new ModificationCommand("A", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); modificationCommandModified.AddEntry(entry2); var entry3 = stateManager.GetOrCreateEntry(new object()); entry3[key] = 3; entry3.SetEntityState(EntityState.Deleted); var modificationCommandDeleted = new ModificationCommand("A", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); modificationCommandDeleted.AddEntry(entry3); var mCC = new ModificationCommandComparer(); Assert.True(0 == mCC.Compare(modificationCommandAdded, modificationCommandAdded)); Assert.True(0 == mCC.Compare(null, null)); Assert.True(0 == mCC.Compare( new ModificationCommand("A", "dbo", new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()), new ModificationCommand("A", "dbo", new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()))); Assert.True(0 > mCC.Compare(null, new ModificationCommand("A", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()))); Assert.True(0 < mCC.Compare(new ModificationCommand("A", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()), null)); Assert.True(0 > mCC.Compare( new ModificationCommand("A", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()), new ModificationCommand("A", "dbo", new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()))); Assert.True(0 < mCC.Compare( new ModificationCommand("A", "dbo", new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()), new ModificationCommand("A", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()))); Assert.True(0 > mCC.Compare( new ModificationCommand("A", "dbo", new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()), new ModificationCommand("A", "foo", new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()))); Assert.True(0 < mCC.Compare( new ModificationCommand("A", "foo", new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()), new ModificationCommand("A", "dbo", new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()))); Assert.True(0 > mCC.Compare( new ModificationCommand("A", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()), new ModificationCommand("B", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()))); Assert.True(0 < mCC.Compare( new ModificationCommand("B", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()), new ModificationCommand("A", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()))); Assert.True(0 > mCC.Compare(modificationCommandModified, modificationCommandAdded)); Assert.True(0 < mCC.Compare(modificationCommandAdded, modificationCommandModified)); Assert.True(0 > mCC.Compare(modificationCommandDeleted, modificationCommandAdded)); Assert.True(0 < mCC.Compare(modificationCommandAdded, modificationCommandDeleted)); Assert.True(0 > mCC.Compare(modificationCommandDeleted, modificationCommandModified)); Assert.True(0 < mCC.Compare(modificationCommandModified, modificationCommandDeleted)); }
public abstract bool AddCommand([NotNull] ModificationCommand modificationCommand);
public abstract bool AddCommand( [NotNull] ModificationCommand modificationCommand, [NotNull] SqlGenerator sqlGenerator);
private bool CanBeInsertedInSameStatement(ModificationCommand firstCommand, ModificationCommand secondCommand) => string.Equals(firstCommand.TableName, secondCommand.TableName, StringComparison.Ordinal) && string.Equals(firstCommand.SchemaName, secondCommand.SchemaName, StringComparison.Ordinal) && firstCommand.ColumnModifications.Where(o => o.IsWrite).Select(o => o.ColumnName).SequenceEqual( secondCommand.ColumnModifications.Where(o => o.IsWrite).Select(o => o.ColumnName)) && firstCommand.ColumnModifications.Where(o => o.IsRead).Select(o => o.ColumnName).SequenceEqual( secondCommand.ColumnModifications.Where(o => o.IsRead).Select(o => o.ColumnName));
protected override bool CanAddCommand(ModificationCommand modificationCommand) => ModificationCommands.Count == 0;
public virtual bool AddCommand( ModificationCommandBatch modificationCommandBatch, ModificationCommand modificationCommand) => Check.NotNull(modificationCommandBatch, nameof(modificationCommandBatch)) .AddCommand(Check.NotNull(modificationCommand, nameof(modificationCommand)));
protected override bool CanAddCommand(ModificationCommand modificationCommand, string newSql) { return(!ModificationCommands.Any()); }
public void ModificationCommand_initialized_correctly_for_added_entities_with_explicitly_specified_key_value() { var entry = Createentry(EntityState.Added); var command = new ModificationCommand("T1", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); command.AddEntry(entry); Assert.Equal("T1", command.TableName); Assert.Null(command.SchemaName); Assert.Equal(EntityState.Added, command.EntityState); Assert.Equal(2, command.ColumnModifications.Count); var columnMod = command.ColumnModifications[0]; Assert.Equal("Col1", columnMod.ColumnName); Assert.Same(entry, columnMod.Entry); Assert.Equal("Id", columnMod.Property.Name); Assert.False(columnMod.IsCondition); Assert.True(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.True(columnMod.IsWrite); Assert.Null(columnMod.BoxedValueReader); columnMod = command.ColumnModifications[1]; Assert.Equal("Col2", columnMod.ColumnName); Assert.Same(entry, columnMod.Entry); Assert.Equal("Name", columnMod.Property.Name); Assert.False(columnMod.IsCondition); Assert.False(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.True(columnMod.IsWrite); Assert.Null(columnMod.BoxedValueReader); }
public void RequiresResultPropagation_false_for_Update_operation_if_no_non_key_store_generated_columns_exist() { var entry = Createentry(EntityState.Modified, generateKeyValues: true); var command = new ModificationCommand("T1", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); command.AddEntry(entry); Assert.False(command.RequiresResultPropagation); }
public void RequiresResultPropagation_true_for_Insert_operation_if_store_generated_columns_exist() { var entry = Createentry( EntityState.Added, generateKeyValues: true, computeNonKeyValue: true); var command = new ModificationCommand("T1", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); command.AddEntry(entry); Assert.True(command.RequiresResultPropagation); }
protected abstract bool CanAddCommand(ModificationCommand modificationCommand, string newSql);
public void ModificationCommand_initialized_correctly_for_deleted_entities_with_concurrency_token() { var stateEntry = CreateStateEntry(EntityState.Deleted, nonKeyStrategy: ValueGenerationOnSave.WhenInsertingAndUpdating); var command = new ModificationCommand("T1", null, new ParameterNameGenerator()); command.AddStateEntry(stateEntry); Assert.Equal("T1", command.TableName); Assert.Equal(EntityState.Deleted, command.EntityState); Assert.Equal(2, command.ColumnModifications.Count); var columnMod = command.ColumnModifications[0]; Assert.Equal("Col1", columnMod.ColumnName); Assert.Same(stateEntry, columnMod.StateEntry); Assert.Equal("Id", columnMod.Property.Name); Assert.True(columnMod.IsCondition); Assert.True(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.False(columnMod.IsWrite); columnMod = command.ColumnModifications[1]; Assert.Equal("Col2", columnMod.ColumnName); Assert.Same(stateEntry, columnMod.StateEntry); Assert.Equal("Name", columnMod.Property.Name); Assert.True(columnMod.IsCondition); Assert.False(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.False(columnMod.IsWrite); }
public void ModificationCommand_throws_for_unknown_entities() { var stateEntry = CreateStateEntry(EntityState.Unknown); var command = new ModificationCommand("T1", null, new ParameterNameGenerator()); Assert.Equal( Strings.FormatModificationFunctionInvalidEntityState(EntityState.Unknown), Assert.Throws<NotSupportedException>(() => command.AddStateEntry(stateEntry)).Message); }
public void RequiresResultPropagation_false_for_Delete_operation() { var stateEntry = CreateStateEntry( EntityState.Deleted, ValueGenerationOnSave.WhenInserting, ValueGenerationOnSave.WhenInsertingAndUpdating); var command = new ModificationCommand("T1", null, new ParameterNameGenerator()); command.AddStateEntry(stateEntry); Assert.False(command.RequiresResultPropagation); }
public void Compare_returns_0_only_for_commands_that_are_equal() { var mCC = new ModificationCommandComparer(); var configuration = new DbContext(new DbContextOptions().UseInMemoryStore(persist: false)).Configuration; var entityType1 = new EntityType(typeof(object)); var key1 = entityType1.AddProperty("Id", typeof(int), shadowProperty: true, concurrencyToken: false); entityType1.SetKey(key1); var stateEntry1 = new MixedStateEntry(configuration, entityType1, new object()); stateEntry1[key1] = 0; stateEntry1.EntityState = EntityState.Added; var modificationCommandAdded = new ModificationCommand(new SchemaQualifiedName("A"), new ParameterNameGenerator()); modificationCommandAdded.AddStateEntry(stateEntry1); var entityType2 = new EntityType(typeof(object)); var key2 = entityType2.AddProperty("Id", typeof(int), shadowProperty: true, concurrencyToken: false); entityType2.SetKey(key2); var stateEntry2 = new MixedStateEntry(configuration, entityType2, new object()); stateEntry2[key2] = 0; stateEntry2.EntityState = EntityState.Modified; var modificationCommandModified = new ModificationCommand(new SchemaQualifiedName("A"), new ParameterNameGenerator()); modificationCommandModified.AddStateEntry(stateEntry2); var entityType3 = new EntityType(typeof(object)); var key3 = entityType3.AddProperty("Id", typeof(int), shadowProperty: true, concurrencyToken: false); entityType3.SetKey(key3); var stateEntry3 = new MixedStateEntry(configuration, entityType3, new object()); stateEntry3[key3] = 0; stateEntry3.EntityState = EntityState.Deleted; var modificationCommandDeleted = new ModificationCommand(new SchemaQualifiedName("A"), new ParameterNameGenerator()); modificationCommandDeleted.AddStateEntry(stateEntry3); Assert.True(0 == mCC.Compare(modificationCommandAdded, modificationCommandAdded)); Assert.True(0 == mCC.Compare(null, null)); Assert.True(0 == mCC.Compare( new ModificationCommand(new SchemaQualifiedName("A", "dbo"), new ParameterNameGenerator()), new ModificationCommand(new SchemaQualifiedName("A", "dbo"), new ParameterNameGenerator()))); Assert.True(0 > mCC.Compare(null, new ModificationCommand(new SchemaQualifiedName("A"), new ParameterNameGenerator()))); Assert.True(0 < mCC.Compare(new ModificationCommand(new SchemaQualifiedName("A"), new ParameterNameGenerator()), null)); Assert.True(0 > mCC.Compare( new ModificationCommand(new SchemaQualifiedName("A"), new ParameterNameGenerator()), new ModificationCommand(new SchemaQualifiedName("A", "dbo"), new ParameterNameGenerator()))); Assert.True(0 < mCC.Compare( new ModificationCommand(new SchemaQualifiedName("A", "dbo"), new ParameterNameGenerator()), new ModificationCommand(new SchemaQualifiedName("A"), new ParameterNameGenerator()))); Assert.True(0 > mCC.Compare( new ModificationCommand(new SchemaQualifiedName("A", "dbo"), new ParameterNameGenerator()), new ModificationCommand(new SchemaQualifiedName("A", "foo"), new ParameterNameGenerator()))); Assert.True(0 < mCC.Compare( new ModificationCommand(new SchemaQualifiedName("A", "foo"), new ParameterNameGenerator()), new ModificationCommand(new SchemaQualifiedName("A", "dbo"), new ParameterNameGenerator()))); Assert.True(0 > mCC.Compare( new ModificationCommand(new SchemaQualifiedName("A"), new ParameterNameGenerator()), new ModificationCommand(new SchemaQualifiedName("B"), new ParameterNameGenerator()))); Assert.True(0 < mCC.Compare( new ModificationCommand(new SchemaQualifiedName("B"), new ParameterNameGenerator()), new ModificationCommand(new SchemaQualifiedName("A"), new ParameterNameGenerator()))); Assert.True(0 > mCC.Compare(modificationCommandModified, modificationCommandAdded)); Assert.True(0 < mCC.Compare(modificationCommandAdded, modificationCommandModified)); Assert.True(0 > mCC.Compare(modificationCommandDeleted, modificationCommandAdded)); Assert.True(0 < mCC.Compare(modificationCommandAdded, modificationCommandDeleted)); Assert.True(0 > mCC.Compare(modificationCommandDeleted, modificationCommandModified)); Assert.True(0 < mCC.Compare(modificationCommandModified, modificationCommandDeleted)); }
public void RequiresResultPropagation_false_for_Insert_operation_if_no_store_generated_columns_exist() { var stateEntry = CreateStateEntry(EntityState.Added); var command = new ModificationCommand("T1", null, new ParameterNameGenerator()); command.AddStateEntry(stateEntry); Assert.False(command.RequiresResultPropagation); }
protected override bool CanAddCommand(ModificationCommand modificationCommand) { return(ModificationCommands.Count == 0); }
public void RequiresResultPropagation_false_for_Update_operation_if_no_non_key_store_generated_columns_exist() { var stateEntry = CreateStateEntry(EntityState.Modified, ValueGenerationOnSave.WhenInserting); var command = new ModificationCommand("T1", null, new ParameterNameGenerator()); command.AddStateEntry(stateEntry); Assert.False(command.RequiresResultPropagation); }
protected abstract bool CanAddCommand([NotNull] ModificationCommand modificationCommand);
public void ModificationCommand_initialized_correctly_for_modified_entities_with_concurrency_token() { var entry = Createentry(EntityState.Modified, computeNonKeyValue: true); var command = new ModificationCommand("T1", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); command.AddEntry(entry); Assert.Equal("T1", command.TableName); Assert.Null(command.SchemaName); Assert.Equal(EntityState.Modified, command.EntityState); Assert.Equal(2, command.ColumnModifications.Count); var columnMod = command.ColumnModifications[0]; Assert.Equal("Col1", columnMod.ColumnName); Assert.Same(entry, columnMod.Entry); Assert.Equal("Id", columnMod.Property.Name); Assert.True(columnMod.IsCondition); Assert.True(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.False(columnMod.IsWrite); Assert.Null(columnMod.BoxedValueReader); columnMod = command.ColumnModifications[1]; Assert.Equal("Col2", columnMod.ColumnName); Assert.Same(entry, columnMod.Entry); Assert.Equal("Name", columnMod.Property.Name); Assert.True(columnMod.IsCondition); Assert.False(columnMod.IsKey); Assert.True(columnMod.IsRead); Assert.False(columnMod.IsWrite); Assert.IsType<GenericBoxedValueReader<string>>(columnMod.BoxedValueReader); }
protected override bool CanAddCommand(ModificationCommand modificationCommand) { return ModificationCommands.Count == 0; }
public void ModificationCommand_initialized_correctly_for_modified_entities_with_identity_key() { var stateEntry = CreateStateEntry(EntityState.Modified, ValueGenerationOnSave.WhenInserting); stateEntry.SetPropertyModified(stateEntry.EntityType.GetKey().Properties[0], isModified: false); var command = new ModificationCommand("T1", null, new ParameterNameGenerator()); command.AddStateEntry(stateEntry); Assert.Equal("T1", command.TableName); Assert.Equal(EntityState.Modified, command.EntityState); Assert.Equal(2, command.ColumnModifications.Count); var columnMod = command.ColumnModifications[0]; Assert.Equal("Col1", columnMod.ColumnName); Assert.Same(stateEntry, columnMod.StateEntry); Assert.Equal("Id", columnMod.Property.Name); Assert.True(columnMod.IsCondition); Assert.True(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.False(columnMod.IsWrite); columnMod = command.ColumnModifications[1]; Assert.Equal("Col2", columnMod.ColumnName); Assert.Same(stateEntry, columnMod.StateEntry); Assert.Equal("Name", columnMod.Property.Name); Assert.False(columnMod.IsCondition); Assert.False(columnMod.IsKey); Assert.False(columnMod.IsRead); Assert.True(columnMod.IsWrite); }
public void Compare_returns_0_only_for_commands_that_are_equal() { var mCC = new ModificationCommandComparer(); var configuration = new DbContext(new DbContextOptions().UseInMemoryStore(persist: false)).Configuration; var entityType1 = new EntityType(typeof(object)); var key1 = entityType1.AddProperty("Id", typeof(int), shadowProperty: true, concurrencyToken: false); entityType1.SetKey(key1); var stateEntry1 = new MixedStateEntry(configuration, entityType1, new object()); stateEntry1[key1] = 0; stateEntry1.EntityState = EntityState.Added; var modificationCommandAdded = new ModificationCommand("A", null, new ParameterNameGenerator()); modificationCommandAdded.AddStateEntry(stateEntry1); var entityType2 = new EntityType(typeof(object)); var key2 = entityType2.AddProperty("Id", typeof(int), shadowProperty: true, concurrencyToken: false); entityType2.SetKey(key2); var stateEntry2 = new MixedStateEntry(configuration, entityType2, new object()); stateEntry2[key2] = 0; stateEntry2.EntityState = EntityState.Modified; var modificationCommandModified = new ModificationCommand("A", null, new ParameterNameGenerator()); modificationCommandModified.AddStateEntry(stateEntry2); var entityType3 = new EntityType(typeof(object)); var key3 = entityType3.AddProperty("Id", typeof(int), shadowProperty: true, concurrencyToken: false); entityType3.SetKey(key3); var stateEntry3 = new MixedStateEntry(configuration, entityType3, new object()); stateEntry3[key3] = 0; stateEntry3.EntityState = EntityState.Deleted; var modificationCommandDeleted = new ModificationCommand("A", null, new ParameterNameGenerator()); modificationCommandDeleted.AddStateEntry(stateEntry3); Assert.True(0 == mCC.Compare(new ModificationCommand("A", null, new ParameterNameGenerator()), new ModificationCommand("A", null, new ParameterNameGenerator()))); Assert.True(0 == mCC.Compare(new ModificationCommand("A", "dbo", new ParameterNameGenerator()), new ModificationCommand("A", "dbo", new ParameterNameGenerator()))); Assert.True(0 == mCC.Compare(null, null)); Assert.True(0 > mCC.Compare(new ModificationCommand("A", null, new ParameterNameGenerator()), new ModificationCommand("A", "dbo", new ParameterNameGenerator()))); Assert.True(0 < mCC.Compare(new ModificationCommand("A", "foo", new ParameterNameGenerator()), new ModificationCommand("A", "dbo", new ParameterNameGenerator()))); Assert.True(0 > mCC.Compare(null, new ModificationCommand("A", null, new ParameterNameGenerator()))); Assert.True(0 < mCC.Compare(new ModificationCommand("A", null, new ParameterNameGenerator()), null)); Assert.True(0 > mCC.Compare(new ModificationCommand("A", null, new ParameterNameGenerator()), new ModificationCommand("B", null, new ParameterNameGenerator()))); Assert.True(0 < mCC.Compare(new ModificationCommand("B", null, new ParameterNameGenerator()), new ModificationCommand("A", null, new ParameterNameGenerator()))); Assert.True(0 > mCC.Compare(new ModificationCommand("A", "dbo", new ParameterNameGenerator()), new ModificationCommand("B", "dbo", new ParameterNameGenerator()))); Assert.True(0 < mCC.Compare(new ModificationCommand("B", "dbo", new ParameterNameGenerator()), new ModificationCommand("A", "dbo", new ParameterNameGenerator()))); Assert.True(0 > mCC.Compare(new ModificationCommand("A", "dbo", new ParameterNameGenerator()), new ModificationCommand("B", null, new ParameterNameGenerator()))); Assert.True(0 < mCC.Compare(new ModificationCommand("B", "dbo", new ParameterNameGenerator()), new ModificationCommand("A", "foo", new ParameterNameGenerator()))); Assert.True(0 > mCC.Compare(modificationCommandModified, modificationCommandAdded)); Assert.True(0 < mCC.Compare(modificationCommandAdded, modificationCommandModified)); Assert.True(0 > mCC.Compare(modificationCommandDeleted, modificationCommandAdded)); Assert.True(0 < mCC.Compare(modificationCommandAdded, modificationCommandDeleted)); Assert.True(0 > mCC.Compare(modificationCommandDeleted, modificationCommandModified)); Assert.True(0 < mCC.Compare(modificationCommandModified, modificationCommandDeleted)); }
public void ModificationCommand_throws_for_unknown_entities() { var entry = Createentry(EntityState.Detached); var command = new ModificationCommand("T1", null, new ParameterNameGenerator(), p => p.Relational(), new BoxedValueReaderSource()); Assert.Equal( Strings.ModificationFunctionInvalidEntityState(EntityState.Detached), Assert.Throws<NotSupportedException>(() => command.AddEntry(entry)).Message); }