public void MapToPartnerModelTestMethod() { // Arrange var branches = CreateBranches(); // Act var resultPartnerModel = PartnerMapper.Map(branches, _categoryModels); var firstBranch = branches.First(); // Assert Assert.AreEqual(resultPartnerModel.Id, firstBranch.PartnerId); Assert.AreEqual(resultPartnerModel.Discount, double.Parse(firstBranch.Discounts.First().Name.First().LocText)); Assert.AreEqual(resultPartnerModel.SelectDiscount, firstBranch.Discounts.First().DiscountType); Assert.AreEqual(resultPartnerModel.Comment, firstBranch.Comment); Assert.AreEqual(resultPartnerModel.Description_En, firstBranch.Description.First(x => x.Lan == Languages.En).LocText); Assert.AreEqual(resultPartnerModel.Description_Ru, firstBranch.Description.First(x => x.Lan == Languages.Ru).LocText); Assert.AreEqual(resultPartnerModel.Image, firstBranch.Image); Assert.AreEqual(resultPartnerModel.Logo, firstBranch.Icon); Assert.AreEqual(resultPartnerModel.Name_En, firstBranch.Name.First(x => x.Lan == Languages.En).LocText); Assert.AreEqual(resultPartnerModel.Name_Ru, firstBranch.Name.First(x => x.Lan == Languages.Ru).LocText); AssertCategories(resultPartnerModel.Categories, firstBranch.CategoryIds); AssertWebAddresses(resultPartnerModel.WebAddresses?.ToList(), firstBranch.WebAddresses?.ToList()); for (var i = 0; i < branches.Count; i++) { var branch = branches[i]; var contact = resultPartnerModel.Contacts?.ToList()[i]; AssertAddress(contact, branch.Address?.ToList()); } for (var i = 0; i < branches.Count; i++) { var branch = branches[i]; var contact = resultPartnerModel.Contacts?.ToList()[i]; AssertPhones(contact, branch.Phones?.ToList()); } for (var i = 0; i < branches.Count; i++) { var branch = branches[i]; var contact = resultPartnerModel.Contacts?.ToList()[i]; AssertCoordinates(contact, branch.Location); } for (var i = 0; i < branches.Count; i++) { var branch = branches[i]; var contact = resultPartnerModel.Contacts?.ToList()[i]; AssertId(contact, branch.Id); } }
public async Task <PartnerModel> GetPartnerDetailsAsync(string partnerId) { var categories = await _categoryApplicationService.GetCategoryListAsync(); var categoriesModels = CategoryMapper.MapToCategoryModels(categories); var partnerBranches = await _partnerApplicationService.GetPartnerDetailsAsync(partnerId); var partnerGalleryImages = await _galleryService.GetGalleryImageIdsForPartner(partnerId); var rating = (await _ratingService.GetPartnerRatingAsync(partnerId)).MapToPartnerStatisticsModel(); var partner = PartnerMapper.Map( partnerBranches?.ToList(), categoriesModels?.ToArray(), partnerGalleryImages?.ToList(), rating); return(partner); }