/// <summary>
        /// Validates that the invocation intercepts a property with the given value and type.
        /// </summary>
        /// <param name="invocation"> The extended <see cref="IInvocation"/> instance. </param>
        /// <param name="type"> The expected property value type. </param>
        /// <param name="value"> The expected property value. </param>
        public static void ShouldHavePropertyValue(this IInvocation invocation, Type type, object?value)
        {
            var feature = invocation.GetFeature <IPropertySetterValue>();

            Assert.Equal(type, feature.Type);
            Assert.Equal(value, feature.Value);
        }
示例#2
0
        /// <summary>
        /// Validates that the invocation has a out parameter with the given name, type and value.
        /// </summary>
        /// <param name="invocation"> The extended <see cref="IInvocation"/> instance. </param>
        /// <param name="name"> The unique name of the out parameter to be validated. </param>
        /// <param name="type"> The type of the out parameter to be validated. </param>
        /// <param name="value"> The value of the out parameter to be validated. </param>
        public static void ShouldHaveParameterOut(this IInvocation invocation, string name, Type type, object?value)
        {
            var feature   = invocation.GetFeature <IParameterOut>();
            var parameter = feature.OutParameterCollection.SingleOrDefault(
                p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase));

            Assert.Equal(name, parameter.Name);
            Assert.Equal(type, parameter.Type);
            Assert.Equal(value, parameter.Value);
        }
示例#3
0
        /// <summary>
        /// Validates that the invocation has <paramref name="count"/> out parameters.
        /// </summary>
        /// <param name="invocation"> The extended <see cref="IInvocation"/> instance. </param>
        /// <param name="count"> The number of out parameter to be validated. </param>
        public static void ShouldHaveParameterOutCountOf(this IInvocation invocation, int count)
        {
            var feature = invocation.GetFeature <IParameterOut>();

            Assert.Equal(count, feature.OutParameterCollection.Count());
        }
        /// <summary>
        /// Validates that the invocation intercepts a property with the given <paramref name="name"/>.
        /// </summary>
        /// <param name="invocation"> The extended <see cref="IInvocation"/> instance. </param>
        /// <param name="name"> The expected property name. </param>
        public static void ShouldInterceptPropertyWithName(this IInvocation invocation, string name)
        {
            var feature = invocation.GetFeature <IPropertyInvocation>();

            Assert.Equal(name, feature.Signature.Name);
        }
        /// <summary>
        /// Validates that the invocation has a given return <paramref name="value"/>.
        /// </summary>
        /// <param name="invocation"> The extended <see cref="IInvocation"/> instance. </param>
        /// <param name="value"> The invocation's return value. </param>
        public static void ShouldHaveReturnValue(this IInvocation invocation, object?value)
        {
            var feature = invocation.GetFeature <IReturnValue>();

            Assert.Equal(value, feature.ReturnValue);
        }
        /// <summary>
        /// Validates that the invocation is of the given asynchronous <paramref name="type"/>.
        /// </summary>
        /// <param name="invocation"> The extended <see cref="IInvocation"/> instance. </param>
        /// <param name="type"> The expected <see cref="AsyncInvocationType"/>. </param>
        public static void ShouldBeAsyncInvocationOfType(this IInvocation invocation, AsyncInvocationType type)
        {
            var feature = invocation.GetFeature <IAsyncInvocation>();

            Assert.Equal(type, feature.Type);
        }