public void UpdateVersionShouldExecuteInsertDataExpression() { var processor = new Mock <IMigrationProcessor>(); var runner = new Mock <IMigrationRunner>(); runner.SetupGet(r => r.Processor).Returns(processor.Object); var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new VersionLoader(runner.Object, asm, conventions); processor.Setup(p => p.Process(It.Is <InsertDataExpression>(expression => expression.SchemaName == loader.VersionTableMetaData.SchemaName && expression.TableName == loader.VersionTableMetaData.TableName && expression.Rows.Any( definition => definition.Any( pair => pair.Key == loader.VersionTableMetaData.ColumnName && pair.Value.Equals(1L)))))) .Verifiable(); loader.UpdateVersionInfo(1); processor.VerifyAll(); }
public void UpdateVersionShouldExecuteInsertDataExpression() { var processor = new Mock <IMigrationProcessor>(); var runner = new Mock <IMigrationRunner>(); runner.SetupGet(r => r.Processor).Returns(processor.Object); var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new VersionLoader(runner.Object, asm, conventions); Func <IDataDefinition, bool> predicate = definition => { if (definition is ExplicitDataDefinition) { IDataValue dataValue = ((ExplicitDataDefinition)definition).Data.First(); return(dataValue.ColumnName == loader.VersionTableMetaData.ColumnName && dataValue.Value.Equals(1L)); } else { return(false); } }; processor.Setup(p => p.Process(It.Is <InsertDataExpression>(expression => expression.SchemaName == loader.VersionTableMetaData.SchemaName && expression.TableName == loader.VersionTableMetaData.TableName && expression.Rows.Any(predicate)))) .Verifiable(); loader.UpdateVersionInfo(1); processor.VerifyAll(); }