static void Main(string[] args)
        {
            //I chose to write this as a console app because it was both simple (as in the exercise wouldn't get lost in the boilerplate of the project)
            // and because console apps can very practically be converted into azure web jobs, which would be a likely method to employ this code.

            if (args.Length < 1)
            {
                Console.WriteLine("You must pass the root service URL as a parameter to this exe");
            }
            else
            {
                string rootServiceURL                = args[0];
                SubstitutionController c             = new SubstitutionController();
                List <RxModel>         prescriptions = c.GetRxList(rootServiceURL + "prescriptions");
                //We may want to limit the number we process at any given time.
                //List<RxModel> subsetOfPrescriptions = prescriptions.GetRange(1, 10);
                List <RxUpdateModel> updates = c.GenerateRxSubstituionList(rootServiceURL, prescriptions);

                //convert the result set to a string
                string jsonResult = JsonConvert.SerializeObject(updates);

                //the secnario wasn't precisely clear how the output was to be formatted
                // (written to a file? submitted to another service?), so for now I'm outputting it to the console.
                Console.Write(jsonResult);
            }
            Console.ReadKey();
        }
Exemple #2
0
        public void TestGetRxList()
        {
            //set up
            SubstitutionController c = new SubstitutionController();
            string serviceURL        = "http://api-sandbox.pillpack.com/prescriptions";
            //execute
            List <RxModel> prescriptions = c.GetRxList(serviceURL);

            //test
            Assert.IsTrue(prescriptions.Count > 0);
        }
Exemple #3
0
        public void TestGenerateSubstitutionList()
        {
            //set up
            SubstitutionController c             = new SubstitutionController();
            string         serviceRootURL        = "http://api-sandbox.pillpack.com/";
            List <RxModel> prescriptions         = c.GetRxList(serviceRootURL + "prescriptions");
            List <RxModel> subsetOfPrescriptions = prescriptions.GetRange(1, 10); //for testing purposes, only do the first 10.
            //execute
            List <RxUpdateModel> updates = c.GenerateRxSubstituionList(serviceRootURL, subsetOfPrescriptions);

            //test
            Assert.IsTrue(updates.Count > 0);
        }