public void GetAverageActCostPerRegion_ValidBnfCodeSupplied_CorrectResultsReturned() { // Mock the queries list decimal queryReturnValue = 0M; foreach (var r in Region.All) { var query = new Mock<ICalcAvgCostByCodeByRegion>(); query.Setup(q => q.Region).Returns(r); query.Setup(q => q.Result).Returns(queryReturnValue++); QueryFactory.Setup( f => f.CalcAvgCostByCodeByRegion(Data.BnfCode1, It.Is<Region>(m => m.Equals(r)), Practices)) .Returns(query.Object); } // Mock reader PrescriptionsReader.Setup(r => r.ExecuteQuery(It.IsAny<List<ICalcAvgCostByCodeByRegion>>())); // Instantiate service PrescriptionsService = new PrescriptionsService(Practices, PrescriptionsReader.Object, QueryFactory.Object); // Call method var result = PrescriptionsService.GetAverageActCostPerRegion(Data.BnfCode1); // Check returned list is correct decimal expectedReturnValue = 0M; Assert.AreEqual(result.Count(r => r.Value == expectedReturnValue++), Region.All.Count); Assert.AreEqual(result.Count, Region.All.Count); // Check DA called // PrescriptionsReader.VerifyAll(); }
private static void Process(PracticesService practicesService, PrescriptionsService prescriptionService) { // Find out how many practices there are in London Console.WriteLine("How many practices are in London?"); int practicesInLondon = practicesService.GetPracticeCountByRegion(Region.London); Console.WriteLine(practicesInLondon); // Find out the average national cost of a peppermint oil prescription Console.WriteLine("What was the average actual cost of all peppermint oil prescriptions?"); decimal averagePepermintOilCost = prescriptionService.GetAverageActCost("0102000T0"); Console.WriteLine(averagePepermintOilCost.ToString("£0.00")); // Find the 5 highest spending postcodes Console.WriteLine("Which 5 post codes have the highest actual spend, and how much did each spend in total?"); // Get postcode spends var totalPostcodeSpends = prescriptionService.GetTotalSpendPerPostcode(); // Get top 5 var topFive = totalPostcodeSpends.OrderByDescending(p => p.Value).Take(5).ToList(); // Write to console topFive.ForEach(p => Console.WriteLine(p.Key + " " + p.Value.ToString("£0.00"))); // Find average price of Flucloxacillin Console.WriteLine( "For each region, what was the average price per prescription of Flucloxacillin," + " and how did this vary from the national mean?"); // Get average cost per region var averageFlucloxacillinRegions = prescriptionService.GetAverageActCostPerRegion("0501012G0"); // Get average cost for country decimal averageFlucloxacillinNational = prescriptionService.GetAverageActCost("0501012G0"); // Write to console Console.WriteLine("National: " + averageFlucloxacillinNational.ToString("£0.00")); averageFlucloxacillinRegions.ForEach( r => Console.WriteLine( r.Key + " " + r.Value.ToString("£0.00") + "; " + (r.Value - averageFlucloxacillinNational).ToString("£0.00"))); // Find by region the percentage difference between the NIC and Act Cost for Console.WriteLine( "For each region for Simeticone, what was the average Actual Cost " + "as a percentage of the average Net Ingredient Cost?"); var actPercentageOfNic = prescriptionService.GetFractionActCostOfNicByRegion("0103050E0"); actPercentageOfNic.ForEach(r => Console.WriteLine(r.Key + " " + r.Value.ToString("0.00%"))); Console.ReadLine(); }