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)); }
private void AssertThatModelHasCorrectMemberships( MembershipOptionModel[] membershipOptionModels) { Assert.That(membershipOptionModels, Is.Not.Null); Assert.That(membershipOptionModels[0].Id, Is.EqualTo(1)); Assert.That(membershipOptionModels[0].Name, Is.EqualTo("Highfaluting Membership 1 Year - $99")); Assert.That(membershipOptionModels[1].Id, Is.EqualTo(2)); Assert.That(membershipOptionModels[1].Name, Is.EqualTo("Highfaluting Membership 2 Years - $198")); Assert.That(membershipOptionModels[2].Id, Is.EqualTo(3)); Assert.That(membershipOptionModels[2].Name, Is.EqualTo("Highfaluting Membership 3 Years - $259")); }
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(); }