private static void ExecAction(object obj) { ICommand command = null; switch (obj) { case InitArgs args: var settings = new ProjectSettings(args.ProjectName, args.RootDirectory, args.IssueUrl); command = new InitCommand(settings); break; case AddArgs args: var changeLogEntry = new ChangeLogEntry(args.Description, args.Author, args.IssueId, args.Type); command = new AddCommand(changeLogEntry); break; case MergeArgs _: command = new MergeCommand(); break; } if (command != null) { command.Execute(); } }
public void then_merge_output_no_ids() { var entities = new List <SampleEntity>(); for (int i = 0; i < 15; i++) { entities.Add(new SampleEntity { GuidNullableProperty = null, DateProperty = DateTime.UtcNow, GuidProperty = Guid.NewGuid() }); } MergeCommand <SampleEntity> command = SUT.Merge <SampleEntity>(entities); command.Compare.IncludeProperty(x => x.Id); command.Output.IncludeProperty(x => x.Id); int changes = command.Execute(MergeType.DeleteMatched); //Assert changes.ShouldEqual(0); entities.ForEach( (entity) => entity.Id.ShouldEqual(0)); }
protected override void When() { MergeCommand <SampleEntity> command = SUT.Merge(InsertItems); command.Compare.IncludeProperty(x => x.Id); _changes = command.Execute(MergeType.Insert); }
protected override void When() { MergeCommand <SampleEntity> command = SUT.Merge(_insertedItems); command.Compare.IncludeProperty(x => x.Id); command.Output .SetExcludeAllByDefault(true) .SetExcludeDbGeneratedByDefault(ExcludeOptions.Exclude); _changes = command.Execute(MergeType.Insert); }
protected override void When() { using (DbContextTransaction ts = SampleDatabase.Database.BeginTransaction()) { SqlTransaction transaction = (SqlTransaction)ts.UnderlyingTransaction; MergeCommand <SampleEntity> command = SUT.Merge(_insertedItems, transaction); command.Compare.IncludeProperty(x => x.Id); _changes = command.Execute(MergeType.Insert); } }
protected override void When() { using (DbContextTransaction ts = SampleDatabase.Database.BeginTransaction()) { SqlTransaction transaction = (SqlTransaction)ts.UnderlyingTransaction; MergeCommand <SampleEntity> command = SUT.Merge(_insertedItems, transaction); command.Compare.IncludeProperty(x => x.Id); command.Output .SetExcludeAllByDefault(true) .SetExcludeDbGeneratedByDefault(ExcludeOptions.Exclude); _changes = command.Execute(MergeType.Insert); } }
protected override void When() { using (var scope = new TransactionScope()) { MergeCommand <SampleEntity> command1 = SUT.Merge(InsertItems); command1.UseInnerTransactionForBatches = false; _changes1 = command1.Execute(MergeType.Insert); MergeCommand <SampleEntity> command2 = SUT.Merge(InsertItems); command2.UseInnerTransactionForBatches = false; _changes2 = command2.Execute(MergeType.Insert); scope.Complete(); } }
protected override void When() { for (int i = 0; i < 15; i++) { _insertedItems[i].DateProperty = new DateTime(2005, 2, 2, 2, 2, i); } MergeCommand <SampleEntity> command = SUT.Merge(_insertedItems); command.Source .IncludeProperty(x => x.Id) .IncludeProperty(x => x.DateProperty); command.Compare .IncludeProperty(x => x.Id); command.UpdateMatched .IncludeProperty(x => x.DateProperty); _changes = command.Execute(MergeType.Update); }
public void then_merge_inserts_multiple_entities_with_output_ids() { int insertCount = 15; var entities = new List <SampleEntity>(); for (int i = 0; i < 15; i++) { entities.Add(new SampleEntity { GuidNullableProperty = null, DateProperty = DateTime.UtcNow, GuidProperty = Guid.NewGuid() }); } MergeCommand <SampleEntity> command = SUT.Merge <SampleEntity>(entities); int changes = command.Execute(MergeType.Insert); //Assert changes.ShouldEqual(insertCount); entities.ForEach( (entity) => entity.Id.ShouldNotEqual(0)); }
protected override void When() { _testName = GetType().FullName; _insertedItems = new List <SampleEntity>(); for (int i = 0; i < 15; i++) { _insertedItems.Add(new SampleEntity { GuidNullableProperty = null, DateProperty = new DateTime(2000, 2, 2, 2, 2, i), GuidProperty = Guid.NewGuid(), StringProperty = _testName }); } MergeCommand <SampleEntity> command = SUT.Merge(_insertedItems); command.Output.ExcludeDbGeneratedByDefault = ExcludeOptions.Exclude; string sql = command.ConstructCommand(MergeType.Insert, _insertedItems); _changes = command.Execute(MergeType.Insert); }
/// <summary> /// Merge the given branch into this Branch using the given merge strategy. /// </summary> /// <param name="other"></param> /// <param name="strategy"></param> public MergeResult Merge(Branch other, MergeStrategy strategy) { return(MergeCommand.Execute(new MergeOptions { Branches = new[] { this, other }, MergeStrategy = strategy })); }
public static MergeResult Merge(MergeOptions options) { return(MergeCommand.Execute(options)); }