public void CreateWithEnumerableParameterReturnsCorrectResult(
            Type argumentType)
        {
            var parameterInfo =
                typeof(SingleParameterType<>)
                    .MakeGenericType(new[] { argumentType })
                    .GetConstructors()
                    .First()
                    .GetParameters()
                    .First();
            var expected = new object();
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r =>
                {
                    Assert.Equal(
                        new SeededRequest(
                            parameterInfo.ParameterType,
                            parameterInfo.Name),
                        r);
                    return expected;
                }
            };
            var sut = new OmitArrayParameterRequestRelay();

            var actual = sut.Create(parameterInfo, context);

            Assert.Equal(expected, actual);
        }
 public void CreateReturnsCorrectResultForNonParameterRequest(
     object request)
 {
     var sut = new OmitArrayParameterRequestRelay();
     var actual = sut.Create(request, new DelegatingSpecimenContext());
     Assert.Equal(new NoSpecimen(request), actual);
 }
        public void CreateWithNonEnumerableParameterRequestReturnsCorrectResult(
            Type argumentType)
        {
            var parameterInfo =
                typeof(SingleParameterType<>)
                    .MakeGenericType(new[] { argumentType })
                    .GetConstructors()
                    .First()
                    .GetParameters()
                    .First();
            var sut = new OmitArrayParameterRequestRelay();

            var dummyContext = new DelegatingSpecimenContext();
            var actual = sut.Create(parameterInfo, dummyContext);

#pragma warning disable 618
            var expected = new NoSpecimen(parameterInfo);
#pragma warning restore 618
            Assert.Equal(expected, actual);
        }
 public void SutIsSpecimenBuilder()
 {
     var sut = new OmitArrayParameterRequestRelay();
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
 }
 public void CreateWithNullContextThrows()
 {
     var sut = new OmitArrayParameterRequestRelay();
     Assert.Throws<ArgumentNullException>(
         () => sut.Create(new object(), null));
 }
        public void CreateReturnsCorrectResultWhenContextReturnsOmitSpecimen(
            Type argumentType)
        {
            var parameterInfo =
                typeof(SingleParameterType<>)
                    .MakeGenericType(new[] { argumentType })
                    .GetConstructors()
                    .First()
                    .GetParameters()
                    .First();
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r => new OmitSpecimen()
            };
            var sut = new OmitArrayParameterRequestRelay();

            var actual = sut.Create(parameterInfo, context);

            var expected = Array.CreateInstance(
                argumentType.GetElementType(),
                0);
            Assert.Equal(expected, actual);
        }