public void WhenHasExpectedResult() { var task = TaskFactory(); var handler = HandlerFactory(task); var sut = new RegisterHandlers(handler); Assert.That( sut.Handlers.Select(_ => _.Handler(null, null, CancellationToken.None)), Is.EquivalentTo(new[] { task })); }
public void WhenHasExpectedResult() { var command = CommandFactory(); var handler = HandlerFactory(command); var sut = new RegisterHandlers(handler); Assert.That( sut.Handlers.SelectMany(_ => _.Handler(null)), Is.EquivalentTo(new[] { command })); }
public void WhenSyncHasExpectedResult() { var signal = new Signal(); var handler = HandlerFactory(signal); var sut = new RegisterHandlers(handler); foreach (var _ in sut.Handlers) { _.Handler(null, null, CancellationToken.None); } Assert.That(signal.IsSet, Is.True); }
public void SuccessiveWhenHasExpectedResult() { var tasks = new List <Task>(); var handlers = new List <Func <object, object, Task> >(); for (var index = 0; index < Random.Next(2, 100); index++) { tasks.Add(TaskFactory()); handlers.Add(HandlerFactory(tasks[tasks.Count - 1])); } var sut = new RegisterHandlers(handlers.ToArray()); Assert.That( sut.Handlers.Select(_ => _.Handler(null, null, CancellationToken.None)), Is.EquivalentTo(tasks)); }
public void SuccessiveWhenHasExpectedResult() { var commands = new List <SqlNonQueryCommand>(); var handlers = new List <Func <object, SqlNonQueryCommand> >(); for (var index = 0; index < Random.Next(2, 100); index++) { commands.Add(CommandFactory()); handlers.Add(HandlerFactory(commands[commands.Count - 1])); } var sut = new RegisterHandlers(handlers.ToArray()); Assert.That( sut.Handlers.SelectMany(_ => _.Handler(null)), Is.EquivalentTo(commands)); }
public void SuccessiveWhenRetainsOrder() { var commands = new List <SqlNonQueryCommand>(); var handlers = new List <Func <object, IEnumerable <SqlNonQueryCommand> > >(); for (var index = 0; index < Random.Next(2, 100); index++) { var handlerCommands = RandomCommandSet(); commands.InsertRange(0, handlerCommands); handlers.Add(HandlerFactory(handlerCommands.ToArray())); } handlers.Reverse(); var sut = new RegisterHandlers(handlers.ToArray()); Assert.That(sut.Handlers.SelectMany(_ => _.Handler(null)), Is.EqualTo(commands)); }
public void SuccessiveWhenHasExpectedResult() { var signals = new List <Signal>(); var handlers = new List <Action <object, object> >(); for (var index = 0; index < Random.Next(2, 100); index++) { signals.Add(new Signal()); handlers.Add(HandlerFactory(signals[signals.Count - 1])); } var sut = new RegisterHandlers(handlers.ToArray()); foreach (var _ in sut.Handlers) { _.Handler(null, null, CancellationToken.None); } Assert.That(signals, Is.All.Matches <Signal>(signal => signal.IsSet)); }
public void SuccessiveWhenRetainsOrder() { var commands = new List<SqlNonQueryCommand>(); var handlers = new List<Func<object, IEnumerable<SqlNonQueryCommand>>>(); for (var index = 0; index < Random.Next(2, 100); index++) { var handlerCommands = RandomCommandSet(); commands.InsertRange(0, handlerCommands); handlers.Add(HandlerFactory(handlerCommands.ToArray())); } handlers.Reverse(); var sut = new RegisterHandlers(handlers.ToArray()); Assert.That(sut.Handlers.SelectMany(_ => _.Handler(null)), Is.EqualTo(commands)); }
public void WhenHasExpectedResult() { var command1 = CommandFactory(); var command2 = CommandFactory(); var handler = HandlerFactory(command1, command2); var sut = new RegisterHandlers(handler); Assert.That( sut.Handlers.SelectMany(_ => _.Handler(null)), Is.EquivalentTo(new[] {command1, command2})); }
public void SuccessiveWhenHasExpectedResult() { var commands = new List<SqlNonQueryCommand>(); var handlers = new List<Func<object, SqlNonQueryCommand[]>>(); for (var index = 0; index < Random.Next(2, 100); index++) { var handlerCommands = RandomCommandSet(); commands.AddRange(handlerCommands); handlers.Add(HandlerFactory(handlerCommands.ToArray())); } var sut = new RegisterHandlers(handlers.ToArray()); Assert.That( sut.Handlers.SelectMany(_ => _.Handler(null)), Is.EqualTo(commands)); }
public void SuccessiveWhenRetainsOrder() { var commands = new List<SqlNonQueryCommand>(); var handlers = new List<Func<object, SqlNonQueryCommand>>(); for (var index = 0; index < Random.Next(2, 100); index++) { commands.Add(CommandFactory()); handlers.Add(HandlerFactory(commands[commands.Count - 1])); } commands.Reverse(); handlers.Reverse(); var sut = new RegisterHandlers(handlers.ToArray()); Assert.That( sut.Handlers.SelectMany(_ => _.Handler(null)), Is.EquivalentTo(commands)); }