public void CombineExplictPropertyWithAutoProperties() { // Fixture setup var expectedText = "Fnaah"; var specifiedCommand = new BindingCommand<DoublePropertyHolder<string, int>, string>(ph => ph.Property1, expectedText); var reservedProperty = new InverseRequestSpecification(specifiedCommand); var customizedBuilder = new Postprocessor<DoublePropertyHolder<string, int>>( new Postprocessor<DoublePropertyHolder<string, int>>( new MethodInvoker(new ModestConstructorQuery()), specifiedCommand), new AutoPropertiesCommand<DoublePropertyHolder<string, int>>(reservedProperty), new AnyTypeSpecification()); var builder = new CompositeSpecimenBuilder( customizedBuilder, Scenario.CreateAutoPropertyBuilder()); var container = new SpecimenContext(builder); // Exercise system var result = container.Resolve(typeof(DoublePropertyHolder<string, int>)); // Verify outcome var actual = Assert.IsAssignableFrom<DoublePropertyHolder<string, int>>(result); Assert.Equal(expectedText, actual.Property1); Assert.Equal(1, actual.Property2); // 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)); }
public void SutIsRequestSpecification() { // Fixture setup var dummySpec = new DelegatingRequestSpecification(); // Exercise system var sut = new InverseRequestSpecification(dummySpec); // Verify outcome Assert.IsAssignableFrom<IRequestSpecification>(sut); // Teardown }
public void SpecificationIsCorrecty() { // Fixture setup var expectedSpec = new DelegatingRequestSpecification(); var sut = new InverseRequestSpecification(expectedSpec); // Exercise system IRequestSpecification result = sut.Specification; // Verify outcome Assert.Equal(expectedSpec, result); // Teardown }
public void IsSatisfiedByReturnsCorrectResult(bool decoratedResult) { // Fixture setup var spec = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => decoratedResult }; var sut = new InverseRequestSpecification(spec); // Exercise system var dummyRequest = new object(); var result = sut.IsSatisfiedBy(dummyRequest); // Verify outcome Assert.Equal(!decoratedResult, result); // Teardown }
public void IsSatisfidByInvokesDecoratedSpecWithCorrectRequest() { // Fixture setup var expectedRequest = new object(); var verified = false; var mock = new DelegatingRequestSpecification { OnIsSatisfiedBy = r => verified = expectedRequest == r }; var sut = new InverseRequestSpecification(mock); // Exercise system sut.IsSatisfiedBy(expectedRequest); // Verify outcome Assert.True(verified, "Mock verified"); // 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); }