/// <summary>
            /// Transforms the supplied builder into another.
            /// </summary>
            /// <param name="builder">The builder to transform.</param>
            /// <returns>
            /// A new <see cref="ISpecimenBuilder"/> created from <paramref name="builder"/>.
            /// </returns>
            /// <remarks>
            /// <para>
            /// Although a <see cref="NoSpecimenOutputGuard"/> throws if the decorated
            /// <see cref="ISpecimenBuilder"/> returns a <see cref="NoSpecimen"/>, this
            /// transformation permits NoSpecimen return values if the request is a
            /// <see cref="SeededRequest"/> for the <see cref="TargetType"/>. This enables the
            /// engine to retry the request with the unwrapped <see cref="Type"/> request.
            /// </para>
            /// </remarks>
            public ISpecimenBuilder Transform(ISpecimenBuilder builder)
            {
                var allowedNoSpecimenFilter = new SeedRequestSpecification(this.targetType);
                var throwSpec = new InverseRequestSpecification(allowedNoSpecimenFilter);

                return(new NoSpecimenOutputGuard(builder, throwSpec));
            }
 public void IsSatisfiedByNullThrows()
 {
     // Fixture setup
     var dummyType = typeof(object);
     var sut = new SeedRequestSpecification(dummyType);
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.IsSatisfiedBy(null));
     // Teardown
 }
 public void SutIsRequestSpecification()
 {
     // Fixture setup
     var dummyType = typeof(object);
     // Exercise system
     var sut = new SeedRequestSpecification(dummyType);
     // Verify outcome
     Assert.IsAssignableFrom<IRequestSpecification>(sut);
     // Teardown
 }
 public void TargetTypeIsCorrect()
 {
     // Fixture setup
     var expectedType = typeof(DayOfWeek);
     var sut = new SeedRequestSpecification(expectedType);
     // Exercise system
     Type result = sut.TargetType;
     // Verify outcome
     Assert.Equal(expectedType, result);
     // Teardown
 }
 public void IsSatisfiedByReturnsCorrectResult(Type specType, Type seedRequestType, bool expectedResult)
 {
     // Fixture setup
     var sut = new SeedRequestSpecification(specType);
     var dummySeed = new object();
     var seededRequest = new SeededRequest(seedRequestType, dummySeed);
     // Exercise system
     var result = sut.IsSatisfiedBy(seededRequest);
     // Verify outcome
     Assert.Equal(expectedResult, result);
     // Teardown
 }
 public void IsSatisfiedByNonSeedReturnsCorrectResult()
 {
     // Fixture setup
     var dummyType = typeof(object);
     var sut = new SeedRequestSpecification(dummyType);
     var nonSeedRequest = new object();
     // Exercise system
     var result = sut.IsSatisfiedBy(nonSeedRequest);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }
 /// <summary>
 /// Transforms the supplied builder into another.
 /// </summary>
 /// <param name="builder">The builder to transform.</param>
 /// <returns>
 /// A new <see cref="ISpecimenBuilder"/> created from <paramref name="builder"/>.
 /// </returns>
 /// <remarks>
 /// <para>
 /// Although a <see cref="NoSpecimenOutputGuard"/> throws if the decorated
 /// <see cref="ISpecimenBuilder"/> returns a <see cref="NoSpecimen"/>, this
 /// transformation permits NoSpecimen return values if the request is a
 /// <see cref="SeededRequest"/> for the <see cref="TargetType"/>. This enables the
 /// engine to retry the request with the unwrapped <see cref="Type"/> request.
 /// </para>
 /// </remarks>
 public ISpecimenBuilder Transform(ISpecimenBuilder builder)
 {
     var allowedNoSpecimenFilter = new SeedRequestSpecification(this.targetType);
     var throwSpec = new InverseRequestSpecification(allowedNoSpecimenFilter);
     return new NoSpecimenOutputGuard(builder, throwSpec);
 }