Наследование: IMortgageApplicationProcessor
        public void SutDoesNotEqualAnonymousObject()
        {
            var sut = new CompositeMortgageApplicationProcessor();
            var anonymous = new object();

            var actual = sut.Equals(anonymous);

            Assert.False(actual);
        }
        public void ProduceOfferConcatenatesResultFromAllComposedNodes()
        {
            // Arrange
            var application = new MortgageApplication();

            var moqRepo = new MockRepository(MockBehavior.Default);
            var r1 = moqRepo.Create<IRendering>().Object;
            var r2 = moqRepo.Create<IRendering>().Object;
            var r3 = moqRepo.Create<IRendering>().Object;
            var r4 = moqRepo.Create<IRendering>().Object;
            var r5 = moqRepo.Create<IRendering>().Object;
            var r6 = moqRepo.Create<IRendering>().Object;
            var r7 = moqRepo.Create<IRendering>().Object;
            var r8 = moqRepo.Create<IRendering>().Object;
            var r9 = moqRepo.Create<IRendering>().Object;

            var node1 = moqRepo.Create<IMortgageApplicationProcessor>();
            var node2 = moqRepo.Create<IMortgageApplicationProcessor>();
            var node3 = moqRepo.Create<IMortgageApplicationProcessor>();

            node1.Setup(n => n.ProduceOffer(application))
                .Returns(new[] { r1, r2, r3 });
            node2.Setup(n => n.ProduceOffer(application))
                .Returns(new[] { r4, r5, r6 });
            node3.Setup(n => n.ProduceOffer(application))
                .Returns(new[] { r7, r8, r9 });

            var sut = new CompositeMortgageApplicationProcessor
            {
                Nodes = new[] { node1.Object, node2.Object, node3.Object }
            };

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

            // Assert
            var expected = new[] { r1, r2, r3, r4, r5, r6, r7, r8, r9 };
            Assert.Equal(expected, actual);
        }
        public void SutDoesNotEqualOtherWithDifferentNodes()
        {
            // Arrange
            var moqRepo = new MockRepository(MockBehavior.Default);

            var sut = new CompositeMortgageApplicationProcessor
            {
                Nodes = new[]
                {
                    moqRepo.Create<IMortgageApplicationProcessor>().Object,
                    moqRepo.Create<IMortgageApplicationProcessor>().Object,
                    moqRepo.Create<IMortgageApplicationProcessor>().Object
                }
            };

            var other = new CompositeMortgageApplicationProcessor
            {
                Nodes = new[]
                {
                    moqRepo.Create<IMortgageApplicationProcessor>().Object,
                    moqRepo.Create<IMortgageApplicationProcessor>().Object,
                    moqRepo.Create<IMortgageApplicationProcessor>().Object
                }
            };

            // Act
            var actual = sut.Equals(other);

            // Assert
            Assert.False(actual);
        }
 public void SutIsMortgageApplicationProcessor()
 {
     var sut = new CompositeMortgageApplicationProcessor();
     Assert.IsAssignableFrom<IMortgageApplicationProcessor>(sut);
 }
        public void SutEqualsOtherWithSameNodes()
        {
            // Arrange
            var moqRepo = new MockRepository(MockBehavior.Default);
            var nodes = new List<IMortgageApplicationProcessor>
            {
                moqRepo.Create<IMortgageApplicationProcessor>().Object,
                moqRepo.Create<IMortgageApplicationProcessor>().Object,
                moqRepo.Create<IMortgageApplicationProcessor>().Object
            };

            var sut = new CompositeMortgageApplicationProcessor
            {
                Nodes = nodes.ToArray()
            };

            var other = new CompositeMortgageApplicationProcessor
            {
                Nodes = nodes.ToArray()
            };

            // Act
            var actual = sut.Equals(other);

            // Arrange
            Assert.True(actual);
        }
        public void ComposeReturnsCorrectResult()
        {
            var sut = new MortgageApplicationProcessorComposer
            {
                LocationProvider = new Mock<ILocationProvider>().Object,
                TimeProvider = new Mock<ITimeProvider>().Object,
                OfferService = new Mock<IOfferService>().Object
            };

            IMortgageApplicationProcessor actual = sut.Compose();

            var expected = new CompositeMortgageApplicationProcessor
            {
                Nodes = new IMortgageApplicationProcessor[]
                {
                    new DateAndLocationMortgageApplicationProcessor
                    {
                        LocationProvider = sut.LocationProvider,
                        TimeProvider = sut.TimeProvider
                    },
                    new GreetingMortgageApplicationProcessor(),
                    new ApplicationDetailsHeadlineMortgageApplicationProcessor(),
                    new PrimaryApplicantMortgageApplicationProcessor(),
                    new ConditionalMortgageApplicationProcessor
                    {
                        Specification = new AnyAdditionalApplicantsSpecification(),
                        TruthProcessor = new AdditionalApplicantsMortgageApplicationProcessor()
                    },
                    new FinancingHeadlineMortgageApplicationProcessor(),
                    new SelfPaymentMortgageApplicationProcessor(),
                    new ConditionalMortgageApplicationProcessor
                    {
                        Specification = new AndMortgageApplicationSpecification
                        {
                            Specifications = new IMortgageApplicationSpecification[]
                            {
                                new CurrentPropertyExistsSpecification(),
                                new CurrentPropertySoldAsFinancingMortgageApplicationSpecification()
                            }
                        },
                        TruthProcessor = new CurrentPropertyMortgageApplicationProcessor()
                    },
                    new PropertyHeadlineMortgageApplicationProcessor(),
                    new PropertyMortgageApplicationProcessor(),
                    new DesiredLoanMortgageApplicationProcessor(),
                    new OfferIntroductionMortgageApplicationProcessor(),
                    new ConditionalMortgageApplicationProcessor
                    {
                        Specification = new DesiredLoanTypeMortgageApplicationSpecification
                        {
                            MatchingLoanType = LoanType.FixedRateAnnuity
                        },
                        TruthProcessor = new FixedRateAnnuityOfferMortgageApplicationProcessor
                        {
                            OfferService = sut.OfferService
                        }
                    },
                    new ConditionalMortgageApplicationProcessor
                    {
                        Specification = new DesiredLoanTypeMortgageApplicationSpecification
                        {
                            MatchingLoanType = LoanType.AdjustableRateAnnuity
                        },
                        TruthProcessor = new AdjustableRateAnnuityOfferMortgageApplicationProcessor
                        {
                            OfferService = sut.OfferService
                        }
                    },
                    new ConditionalMortgageApplicationProcessor
                    {
                        Specification = new DesiredLoanTypeMortgageApplicationSpecification
                        {
                            MatchingLoanType = LoanType.InterestOnly
                        },
                        TruthProcessor = new InterestOnlyOfferMortgageApplicationProcessor
                        {
                            OfferService = sut.OfferService
                        }
                    }
                }
            };
            Assert.Equal(expected, actual);
        }