/// <summary>
 /// Adds an <see cref="IViewLocationExpander"/> to <paramref name="descriptors"/>.
 /// </summary>
 /// <param name="descriptors">A list of <see cref="ViewLocationExpanderDescriptor"/>.</param>
 /// <param name="viewLocationExpander">An <see cref="IViewLocationExpander"/> instance.</param>
 /// <returns>A <see cref="ViewLocationExpanderDescriptor"/> representing the added instance.</returns>
 public static ViewLocationExpanderDescriptor Add(
     [NotNull] this IList<ViewLocationExpanderDescriptor> descriptors,
     [NotNull] IViewLocationExpander viewLocationExpander)
 {
     var descriptor = new ViewLocationExpanderDescriptor(viewLocationExpander);
     descriptors.Add(descriptor);
     return descriptor;
 }
        /// <summary>
        /// Adds an <see cref="IViewLocationExpander"/> to <paramref name="descriptors"/>.
        /// </summary>
        /// <param name="descriptors">A list of <see cref="ViewLocationExpanderDescriptor"/>.</param>
        /// <param name="viewLocationExpander">An <see cref="IViewLocationExpander"/> instance.</param>
        /// <returns>A <see cref="ViewLocationExpanderDescriptor"/> representing the added instance.</returns>
        public static ViewLocationExpanderDescriptor Add(
            [NotNull] this IList <ViewLocationExpanderDescriptor> descriptors,
            [NotNull] IViewLocationExpander viewLocationExpander)
        {
            var descriptor = new ViewLocationExpanderDescriptor(viewLocationExpander);

            descriptors.Add(descriptor);
            return(descriptor);
        }
        public void ConstructorSetsViewLocationExpanderAndType()
        {
            // Arrange
            var expander = new TestViewLocationExpander();

            // Act
            var descriptor = new ViewLocationExpanderDescriptor(expander);

            // Assert
            Assert.Same(expander, descriptor.Instance);
            Assert.Equal(expander.GetType(), descriptor.OptionType);
        }
        public void ConstructorSetsViewLocationExpanderType()
        {
            // Arrange
            var type = typeof(TestViewLocationExpander);

            // Act
            var descriptor = new ViewLocationExpanderDescriptor(type);

            // Assert
            Assert.Equal(type, descriptor.OptionType);
            Assert.Null(descriptor.Instance);
        }
        /// <summary>
        /// Inserts a type representing a <see cref="IViewLocationExpander"/> in to <paramref name="descriptors"/> at
        /// the specified <paramref name="index"/>.
        /// </summary>
        /// <param name="descriptors">A list of <see cref="ViewLocationExpanderDescriptor"/>.</param>
        /// <param name="index">The zero-based index at which <paramref name="viewLocationExpanderType"/>
        /// should be inserted.</param>
        /// <param name="viewLocationExpanderType">Type representing an <see cref="IViewLocationExpander"/></param>
        /// <returns>A <see cref="ViewLocationExpanderDescriptor"/> representing the inserted instance.</returns>
        public static ViewLocationExpanderDescriptor Insert(
            [NotNull] this IList<ViewLocationExpanderDescriptor> descriptors,
            int index,
            [NotNull] Type viewLocationExpanderType)
        {
            if (index < 0 || index > descriptors.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            var descriptor = new ViewLocationExpanderDescriptor(viewLocationExpanderType);
            descriptors.Insert(index, descriptor);
            return descriptor;
        }
        /// <summary>
        /// Insert an <see cref="IViewLocationExpander"/> in to <paramref name="descriptors"/> at the specified
        /// <paramref name="index"/>.
        /// </summary>
        /// <param name="descriptors">A list of <see cref="ViewLocationExpanderDescriptor"/>.</param>
        /// <param name="index">The zero-based index at which <paramref name="viewLocationExpander"/>
        /// should be inserted.</param>
        /// <param name="viewLocationExpander">An <see cref="IViewLocationExpander"/> instance.</param>
        /// <returns>A <see cref="ViewLocationExpanderDescriptor"/> representing the added instance.</returns>
        public static ViewLocationExpanderDescriptor Insert(
            [NotNull] this IList <ViewLocationExpanderDescriptor> descriptors,
            int index,
            [NotNull] IViewLocationExpander viewLocationExpander)
        {
            if (index < 0 || index > descriptors.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            var descriptor = new ViewLocationExpanderDescriptor(viewLocationExpander);

            descriptors.Insert(index, descriptor);
            return(descriptor);
        }