public void ApplyValueTypeReturnValueArrangement()
        {
            // Given
            var signature = typeof(IFooFuncValueTypeParameterless <int>)
                            .GetMethod(nameof(IFooFuncValueTypeParameterless <int> .MethodWithoutParameter)) ?? throw new InvalidOperationException();
            var returnValueFeature = new ReturnValueInvocation <int>();
            var invocation         = new Invocation(signature, returnValueFeature);
            var arrangment         = new ReturnValueArrangement <int>(signature, 42);

            // When
            arrangment.ApplyTo(invocation);

            // Then
            Assert.True(invocation.HasFeature <IReturnValue <int> >());
            var feature = invocation.GetFeature <IReturnValue <int> >();

            Assert.Equal(42, feature.ReturnValue);
        }
        public void EnsureNoArrangentIsAppliedToNonMatchingInvocation()
        {
            // Given
            var valueTypeSignature = typeof(IFooFuncValueTypeParameterless <int>)
                                     .GetMethod(nameof(IFooFuncValueTypeParameterless <int> .MethodWithoutParameter)) ?? throw new InvalidOperationException();
            var referenceTypeSignature = typeof(IFooFuncReferenceTypeParameterless <object>)
                                         .GetMethod(nameof(IFooFuncReferenceTypeParameterless <object> .MethodWithoutParameter)) ?? throw new InvalidOperationException();
            var returnValueFeature = new ReturnValueInvocation <int>();
            var invocation         = new Invocation(referenceTypeSignature, returnValueFeature);
            var arrangment         = new ReturnValueArrangement <int>(valueTypeSignature, 42);

            // When
            arrangment.ApplyTo(invocation);

            // Then
            Assert.True(invocation.HasFeature <IReturnValue <int> >());
            var feature = invocation.GetFeature <IReturnValue <int> >();

            Assert.Equal(default, feature.ReturnValue);
        public void ApplyValueTypeGetterReturnValueArrangement()
        {
            // Given
            var signature = typeof(IFooValueTypeGetter <int>)
                            .GetProperty(nameof(IFooValueTypeGetter <int> .Getter)) ?? throw new InvalidOperationException();
            var getter = signature.GetGetMethod() ?? throw new InvalidOperationException();

            var propertyFeature    = new PropertyInvocation(signature);
            var returnValueFeature = new ReturnValueInvocation <int>();
            var invocation         = new Invocation(getter, propertyFeature, returnValueFeature);
            var arrangment         = new ReturnValueArrangement <int>(getter, 42);

            // When
            arrangment.ApplyTo(invocation);

            // Then
            Assert.True(invocation.HasFeature <IReturnValue <int> >());
            var feature = invocation.GetFeature <IReturnValue <int> >();

            Assert.Equal(42, feature.ReturnValue);
        }
        public void ApplyAsyncValueTypeTaskReturnValueArrangement()
        {
            // Given
            var signature = typeof(IFooGenericTaskValueTypeParameterless)
                            .GetMethod(nameof(IFooGenericTaskValueTypeParameterless.MethodWithoutParameterAsync)) ?? throw new InvalidOperationException();
            var asyncFeature = new AsyncGenericTaskInvocation <int>();
            var invocation   = new Invocation(signature, asyncFeature);
            var arrangment   = new ReturnValueArrangement <Task <int> >(signature, Task.FromResult(42));

            // When
            arrangment.ApplyTo(invocation);

            // Then
            Assert.True(invocation.HasFeature <IAsyncInvocation <Task <int> > >());
            var feature = invocation.GetFeature <IAsyncInvocation <Task <int> > >();

            Assert.IsAssignableFrom <Task <int> >(feature.AsyncReturnValue);

            Assert.True(invocation.HasFeature <IReturnValue <int> >());
            var returnValueFeature = invocation.GetFeature <IReturnValue <int> >();

            Assert.Equal(42, returnValueFeature.ReturnValue);
        }