Ploeh.Samples.Loan.ConditionalMortgageApplicationProcessor.ProduceOffer C# (CSharp) Method

ProduceOffer() public method

public ProduceOffer ( MortgageApplication application ) : IEnumerable
application Ploeh.Samples.Loan.DataCollection.MortgageApplication
return IEnumerable
        public IEnumerable<IRendering> ProduceOffer(MortgageApplication application)
        {
            if (this.Specification.IsSatisfiedBy(application))
                return this.TruthProcessor.ProduceOffer(application);

            return Enumerable.Empty<IRendering>();
        }

Usage Example

        public void ProduceOfferReturnsCorrectResultWhenSpecificationIsSatisfied()
        {
            // Arrange
            var application = new MortgageApplication();

            var sut = new ConditionalMortgageApplicationProcessor
            {
                Specification = new Mock<IMortgageApplicationSpecification>().Object,
                TruthProcessor = new Mock<IMortgageApplicationProcessor>().Object
            };

            Mock.Get(sut.Specification)
                .Setup(s => s.IsSatisfiedBy(application))
                .Returns(true);

            var expected = new []
            {
                new Mock<IRendering>().Object,
                new Mock<IRendering>().Object,
                new Mock<IRendering>().Object,
            };

            Mock.Get(sut.TruthProcessor)
                .Setup(p => p.ProduceOffer(application))
                .Returns(expected);

            // Act
            var actual = sut.ProduceOffer(application);

            // Assert
            Assert.Equal(expected, actual);
        }
All Usage Examples Of Ploeh.Samples.Loan.ConditionalMortgageApplicationProcessor::ProduceOffer
ConditionalMortgageApplicationProcessor