//todo: should we add a AddIdSyncComponents method? private async Task SyncComponentsToGraphReplicaSet() { var commands = MoreEnumerable .TraverseBreadthFirst((IGraphMergeContext)_graphMergeContext !, ctx => ctx !.ChildContexts) .SelectMany(ctx => { var nodeCommands = new List <ICommand>(); if (ctx.ReplaceRelationshipsCommand.Relationships.Any()) { nodeCommands.Add(ctx.ReplaceRelationshipsCommand); } if (ctx.ExtraCommands.Any()) { nodeCommands.AddRange(ctx.ExtraCommands); } if (!ctx.SyncNameProvider.GraphSyncPartSettings.PreexistingNode) { nodeCommands.Add(ctx.MergeNodeCommand); } return(nodeCommands); }) .Reverse() .ToArray(); await _graphMergeContext !.GraphReplicaSet.Run(commands); }
public async Task Run_Command_LimitedToOneInstance_CommandIsRunOnCorrectInstance() { const int limitedToInstance = 2; GraphReplicaSet = new GraphReplicaSet(ReplicaSetName, GraphInstances, Logger, limitedToInstance); await GraphReplicaSet.Run(Command); int index = 0; foreach (var graph in GraphInstances) { var calls = Fake.GetCalls(graph).ToList(); TestOutputHelper.WriteLine($"Graph #{index}: Run() called x{calls.Count}."); ++index; } index = 0; foreach (var graph in GraphInstances) { A.CallTo(() => graph.Run(A <ICommand> ._)) .MustHaveHappened(index == limitedToInstance ? 1 : 0, Times.Exactly); ++index; } }