コード例 #1
0
        public void GetInvalidRoadStatusTest()
        {
            //Arrange
            var road = "A455";

            //Act
            var result = ApiRequestProcessor.ProcessApiRequest(road);

            //Assert
            Assert.AreEqual(1, result.Item1);
            Assert.IsTrue(result.Item2.Contains($"{road} is not a valid road."));

            Console.WriteLine(result.Item2);
        }
コード例 #2
0
        public void GetValidRoadStatusTest()
        {
            //Arrange
            var road = "A2";

            //Act
            var result = ApiRequestProcessor.ProcessApiRequest(road);

            //Assert
            Assert.AreEqual(0, result.Item1);
            Assert.IsTrue(result.Item2.Contains($"The status of the {road} is as follows"));
            Assert.IsTrue(result.Item2.Contains("Road Status is"));
            Assert.IsTrue(result.Item2.Contains("Road Status Description is"));

            Console.WriteLine(result.Item2);
        }
コード例 #3
0
        public void GetInvalidURLResponeTest()
        {
            //Arrange
            var road        = "A2";
            var appSettings = ConfigurationManager.AppSettings;

            appSettings["ApiURL"] = "invalidApiURL";  //Invalid ApiURL

            //Act
            var result = ApiRequestProcessor.ProcessApiRequest(road);

            //Assert
            Assert.AreEqual(4, result.Item1);
            Assert.IsTrue(result.Item2.Contains("Error"));

            Console.WriteLine(result.Item2);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: AntonyLeonard/RoadStatus
        /// <summary>
        /// This Main method passes parameter to an API call
        /// to get road status
        /// </summary>
        /// <param name="args"></param>
        /// <returns>integer as exitcode
        ///          -1: Default value, 0: Valid Road Status
        ///           1: Invalid Road Status, 2: Command Parameter cannot be parsed
        ///           4: Fatal Error like request with Unauthorised credential
        ///              or unable to establish server connection
        ///          </returns>
        public static int Main(string[] args)
        {
            var result = new Tuple <int, string>(-1, string.Empty);

            _log.InfoFormat("Application started successfully");

            if (args.Length == 0)
            {
                result = Tuple.Create(2, "Input is not valid");
            }
            else
            {
                result = ApiRequestProcessor.ProcessApiRequest(args[0]);
            }

            Console.WriteLine(result.Item2);
            _log.InfoFormat("Application returned code: {0}", result.Item1);

            return(result.Item1);
        }