Exemplo n.º 1
0
        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 RecipientDescription CreateFrom(Recipient recipient)
        {
            var recipientType = recipient is TypeRecipient ir ? ir.Type : null;

            var description = new RecipientDescription(
                recipient.Id,
                recipient.Name,
                recipientType,
                recipient.Lifetime,
                recipient.CollisionStrategy);

            return(description);
        }
        public void Can_be_deconstructed()
        {
            var expectedDescription = new RecipientDescription(
                Guid.NewGuid(),
                "My name is",
                typeof(SomeType),
                Lifetime.Singleton,
                CollisionStrategy.UseAllMethodsMatching);

            var invocation = new IncompleteInvocation(expectedDescription);

            var(id, name, type, lifetime, strategy) = invocation.Recipient;

            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);
        }
Exemplo n.º 4
0
 protected Invocation(RecipientDescription recipient)
 {
     Recipient = recipient;
 }
 internal IncompleteInvocation(RecipientDescription recipient) : base(recipient)
 {
 }