public void Valid_Returns_Success()
        {
            var validArgs = new string[] {
                "--resource",
                "DocumentReference",
                "--method",
                "GET",
                "--parameters",
                "subject|code",
                "--format",
                "JSON",
                "--setheaders",
                "fromasid|value"
            };

            var fhirCommand = new FhirCommand(validArgs);

            var fhirArgs = fhirCommand.StoreValidOptions();

            Assert.True(fhirArgs.Success, fhirArgs.Message);

            var fhirParse = fhirCommand.ParseCommand();

            Assert.True(fhirParse.Success, fhirParse.Message);
        }
        public void Valid_Returns_Success()
        {
            var validArgs = new string[] {
                "--resource",
                "DocumentReference",
                "--method",
                "POST",
                "--body",
                "{'OrgCode': 'MHT01','NhsNumber': '3656987882','Url': 'http://example.org/xds/mhd/Binary/test12345.pdf','ContentType': 'application/pdf','TypeCode': '718347001','TypeDisplay': 'Mental health care plan','Creation': '2018-04-02T11:15:45+00:00'}",
                "--format",
                "JSON",
                "--setheaders",
                "fromasid|value"
            };

            var fhirCommand = new FhirCommand(validArgs);

            var fhirArgs = fhirCommand.StoreValidOptions();

            Assert.True(fhirArgs.Success, fhirArgs.Message);

            var fhirParse = fhirCommand.ParseCommand();

            Assert.True(fhirParse.Success, fhirParse.Message);
        }
        public void Invalid_Resource_Returns_Fail()
        {
            var validArgs = new string[] {
                "--resource",
                "fakeresourcebla",
                "--method",
                "GET",
                "--parameters",
                "subject|code"
            };

            var fhirCommand = new FhirCommand(validArgs);

            var fhirArgs = fhirCommand.StoreValidOptions();

            Assert.False(fhirArgs.Success);
        }
Exemplo n.º 4
0
        public void Invalid_Method_Returns_Fail()
        {
            var validArgs = new string[] {
                "--resource",
                "DocumentReference",
                "--method",
                "PUT",
                "--body",
                "{'OrgCode': 'MHT01','NhsNumber': '3656987882','Url': 'http://example.org/xds/mhd/Binary/test12345.pdf','ContentType': 'application/pdf','TypeCode': '718347001','TypeDisplay': 'Mental health care plan','Creation': '2018-04-02T11:15:45+00:00'}"
            };

            var fhirCommand = new FhirCommand(validArgs);

            var fhirArgs = fhirCommand.StoreValidOptions();

            Assert.False(fhirArgs.Success);
        }
        public void Invalid_Missing_Body_Returns_Fail()
        {
            var validArgs = new string[] {
                "--resource",
                "DocumentReference",
                "--method",
                "POST",
                "--setheaders",
                "fromasid|value"
            };

            var fhirCommand = new FhirCommand(validArgs);

            var fhirArgs = fhirCommand.StoreValidOptions();

            var fhirParse = fhirCommand.ParseCommand();

            Assert.False(fhirParse.Success);
        }
        public void Invalid_Null_Parameters_Returns_Fail()
        {
            var validArgs = new string[] {
                "--resource",
                "DocumentReference",
                "--method",
                "GET",
                "--parameters",
                null,
                "--format",
                "JSON"
            };

            var fhirCommand = new FhirCommand(validArgs);

            var fhirArgs = fhirCommand.StoreValidOptions();

            var fhirParse = fhirCommand.ParseCommand();

            Assert.False(fhirParse.Success);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var cmdHelper = new FhirCommand(args);

            var argsList = args.ToList();

            if (argsList.FirstOrDefault(a => new List <string> {
                "-h", "--help"
            }.Contains(a.ToLowerInvariant())) != null)
            {
                PrintHelp();
                return;
            }

            if (argsList.FirstOrDefault(a => new List <string> {
                "-v", "--version"
            }.Contains(a.ToLowerInvariant())) != null)
            {
                PrintVersion();
                return;
            }

            var validOptions = cmdHelper.StoreValidOptions();

            if (!validOptions.Success)
            {
                PrintError(validOptions.Message);
                return;
            }

            var validCmd = cmdHelper.ParseCommand();

            if (!validCmd.Success)
            {
                PrintError(validCmd.Message);
                return;
            }


            var response = cmdHelper.RunCommand().Result;

            if (!response.Success)
            {
                PrintError(response.Message);
                return;
            }

            var outputLocation = cmdHelper.GetOutputLocation();

            if (outputLocation == null)
            {
                Console.WriteLine(response.Result);
            }
            else
            {
                if (!outputLocation.Success)
                {
                    PrintError(outputLocation.Message);
                    return;
                }

                File.WriteAllText(outputLocation.Result, response.Result);
            }


            Console.WriteLine("Request Complete.");
            Console.WriteLine("Press any key to stop...");
            Console.ReadKey();
        }