Пример #1
0
        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);
        }
Пример #2
0
        public void ProduceOfferReturnsCorrectResultWhenSpecificationIsNotSatisfied()
        {
            // 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(false);
            Mock.Get(sut.TruthProcessor)
            .Setup(s => s.ProduceOffer(It.IsAny <MortgageApplication>()))
            .Returns(new[] { new Mock <IRendering>().Object });

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

            // Assert
            Assert.Empty(actual);
        }