public void GetTotalSpendPerPostcode_DictionaryReturnedFromDA_DictionaryReturned()
        {
            // Create dictionary to be returned
            regionSpends = new Dictionary<string, decimal>
                               {
                                   { Region.EastMidlands.ToString(), 5M },
                                   { Region.EastOfEngland.ToString(), 6M }
                               };
            // Mock query
            query.Setup(q => q.Result).Returns(regionSpends);
            QueryFactory.Setup(f => f.CalcTotalSpendPerPostcode(Practices)).Returns(query.Object);
            // Mock reader
            PrescriptionsReader.Setup(r => r.ExecuteQuery(query.Object));
            // Instantiate service
            PrescriptionsService = new PrescriptionsService(Practices, PrescriptionsReader.Object, QueryFactory.Object);

            // Call method
            var result = PrescriptionsService.GetTotalSpendPerPostcode();

            // Check data returned unchanged
            Assert.IsTrue(result[Region.EastMidlands.ToString()] == 5M && result[Region.EastOfEngland.ToString()] == 6M);
            Assert.AreEqual(regionSpends.Count, 2);
            // Check reader was called
            PrescriptionsReader.VerifyAll();
        }
예제 #2
0
        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();
        }