Beispiel #1
0
        public void HydrateIndexModelShouldSetTheCreditCardTypesAndMembershipOptions()
        {
            var indexModel = new IndexModel();

            var membershipOffers = new MembershipOffer[0];

            _mockOrderRepository.Setup(
                repos => repos.GetAllActiveMembershipOffers())
            .Returns(membershipOffers);

            var membershipOptionModels = new MembershipOptionModel[0];

            _mockIndexModelMapper.Setup(
                mapper => mapper.MapDomainToModels(
                    membershipOffers))
            .Returns(membershipOptionModels);

            var selectListItems = new SelectListItem[0];

            _mockCreditCardListItemMapper.Setup(
                mapper => mapper.MapCreditCardsToListItems(
                    It.IsAny <CreditCardType[]>()))
            .Returns(selectListItems);

            _indexModelRepository.HydrateIndexModel(
                indexModel);

            Assert.That(indexModel.MembershipOptions, Is.EqualTo(membershipOptionModels));
            Assert.That(indexModel.CreditCardTypes, Is.EqualTo(selectListItems));
        }
Beispiel #2
0
        public MembershipOptionModel[] MapDomainToModels(
            MembershipOffer[] membershipOffers)
        {
            var membershipOptionModels = new List <MembershipOptionModel>();

            foreach (var allActiveMembershipOffer in membershipOffers)
            {
                var membershipOptionModel = new MembershipOptionModel
                {
                    Id   = allActiveMembershipOffer.Id,
                    Name = (allActiveMembershipOffer.ExternalName + " - " + allActiveMembershipOffer.Price.ToString("$###,###,##0"))
                };

                membershipOptionModels.Add(membershipOptionModel);
            }

            return(membershipOptionModels.ToArray());
        }