public void GetGroupsAndAddressForPlan_Success() { AddressModel payorAddresses = new AddressModel() { AddressID = 1, AddressTypeID = 1 }; PayorPlanGroup payorPlanGroup = new PayorPlanGroup() { GroupID = "1", GroupName = "Group1", PayorGroupID = 1, PayorPlanID = 2 }; PlanGroupAndAddressesModel groupAndAddressesModelSuccess = new PlanGroupAndAddressesModel() { PayorAddresses = new List <Model.Address.AddressModel> { payorAddresses }, PlanGroups = new List <PayorPlanGroup> { payorPlanGroup } }; List <PlanGroupAndAddressesModel> payorPlanGroupList = new List <PlanGroupAndAddressesModel> { groupAndAddressesModelSuccess }; Response <PlanGroupAndAddressesModel> payorPlanGroupExpectedResponse = new Response <PlanGroupAndAddressesModel>(); payorPlanGroupExpectedResponse.DataItems = payorPlanGroupList; mock.Setup(r => r.GetGroupsAndAddressForPlan(It.IsAny <int>())) .Returns(payorPlanGroupExpectedResponse); //Act var getpayorPlans = contactBenefitController.GetGroupsAndAddressForPlan(planID); var response = getpayorPlans as HttpResult <Response <PayorPlanGroup> >; //Assert Assert.IsNotNull(response, "Response can't be null"); Assert.IsNotNull(response.Value.DataItems, "Data items can't be null"); Assert.IsTrue(response.Value.DataItems.Count() > 0, "Atleast one payor plan group must exists."); }
public static PlanGroupAndAddressModelViewModel ToViewModel(this PlanGroupAndAddressesModel entity) { if (entity == null) { return(null); } var model = new PlanGroupAndAddressModelViewModel { PayorAddresses = new List <AddressViewModel>() }; if (entity.PayorAddresses != null && entity.PayorAddresses.Count > 0) { entity.PayorAddresses.ForEach(delegate(AddressModel m) { var transformedModel = m.ToViewModel(); model.PayorAddresses.Add(transformedModel); }); } model.PlanGroups = entity.PlanGroups; model.ModifiedOn = entity.ModifiedOn; return(model); }