public void CalculateCall() { var calculationService = new Mock<IPriceCalculationService>(); var viewModel = new PriceCalculationViewModel { PlanType = PlanType.VoicePlan1 }; calculationService.Setup(x => x.CalculatePrice(It.IsAny<PriceCalculationViewModel>())).Returns(new Price(10)); var controller = new HomeController(calculationService.Object); var result = controller.CalculateCall(viewModel).As<PartialViewResult>(); result.Should().NotBeNull(); result.Model.As<Price>().Value.Should().Be(10); }
public Price CalculatePrice(PriceCalculationViewModel priceCalculation) { var voiceCall = new VoiceCall(new TimeSpan(0, 0, priceCalculation.Units), _standardHardcodedCall); var textCall = new TextCall(priceCalculation.Units, _standardHardcodedCall); var dataCall = new DataCall(priceCalculation.Units.KByte(), _standardHardcodedCall); switch (priceCalculation.PlanType) { case PlanType.VoicePlan1: return _voiceTaxation.CalculatePrice(voiceCall, StandardPlans.VoicePlan1); case PlanType.VoicePlan2: return _voiceTaxation.CalculatePrice(voiceCall, StandardPlans.VoicePlan2); case PlanType.DataPlan1: return _dataTaxation.CalculatePrice(dataCall, StandardPlans.DataPlan1); case PlanType.DataPlan2: return _dataTaxation.CalculatePrice(dataCall, StandardPlans.DataPlan2); case PlanType.TextPlan1: return _textTaxation.CalculatePrice(textCall, StandardPlans.TextPlan1); case PlanType.TextPlan2: return _textTaxation.CalculatePrice(textCall, StandardPlans.TextPlan2); default: throw new ArgumentOutOfRangeException(); } }