public async Task PublishCore_全てのハンドラが非同期で実行され完了を待機されない() { var testMediator = new TestServiceLikeMediator(); var taskList = new List <Task>(); var messageList = new List <string>(); var ping = new TestPing(); Func <INotification, CancellationToken, Task> CreateFunc(string id, int wait) { var task = new Task(() => { Thread.Sleep(wait); messageList.Add(id); }); taskList.Add(task); return(new Func <INotification, CancellationToken, Task>((ev, ct) => { ev.Should().BeSameAs(ping); task.Start(); return task; })); } await testMediator.Run(new[] { CreateFunc("1", 350), CreateFunc("2", 500), CreateFunc("3", 200) }, ping); await Task.WhenAll(taskList); messageList.Should().HaveCount(3).And.Contain("1", "2", "3"); }
internal Communication SetResponse() { switch (CommunicationReceived.Type) { case EType.CREATE: var address = CommunicationReceived.Content; var success = TestPing.Test(address); DomainRepository.add(new Domain { Address = address, Success = success }); return(SetCommunication(DomainRepository.GetAll)); case EType.READ: return(SetCommunication(DomainRepository.GetAll)); default: return(SetCommunication(null)); } }