public void Can_be_deconstructed() { var expectedDescription = new RecipientDescription( Guid.NewGuid(), "My name is", typeof(SomeType), Lifetime.Singleton, CollisionStrategy.UseAllMethodsMatching); var expectedException = new Exception(); var expectedDuration = TimeSpan.FromSeconds(1); var invocation = new FaultedInvocation( expectedDescription, expectedException, expectedDuration); var((id, name, type, lifetime, strategy), exception, duration) = invocation; Assert.Equal(expectedDescription.Id, id); Assert.Equal(expectedDescription.Name, name); Assert.Equal(expectedDescription.Type, type); Assert.Equal(expectedDescription.Lifetime, lifetime); Assert.Equal(expectedDescription.CollisionStrategy, strategy); Assert.Equal(expectedException, exception); Assert.Equal(expectedDuration, duration); }
public static AggregatedResponse <TResponse> CreateFrom <TResponse>( IEnumerable <RecipientRunner <TResponse> > invocations) { var completed = new List <CompletedInvocation <TResponse> >(); var faulted = new List <FaultedInvocation>(); var incomplete = new List <IncompleteInvocation>(); foreach (var invocation in invocations) { var recipientDescription = RecipientDescriptionFactory.CreateFrom(invocation.Recipient); if (invocation.CompletedSuccessfully) { var completedInvocation = new CompletedInvocation <TResponse>( recipientDescription, invocation.Result, invocation.Duration); completed.Add(completedInvocation); } else if (invocation.Faulted) { var faultedInvocation = new FaultedInvocation( recipientDescription, invocation.Exception, invocation.Duration); faulted.Add(faultedInvocation); } else { incomplete.Add(new IncompleteInvocation(recipientDescription)); } } return(new AggregatedResponse <TResponse>(completed, faulted, incomplete)); }