Example #1
0
        public void Test_canGetSystemTimeResponseAndTimeCloseToRealTimeWithWorkingURIAsync_forFormatDateAndTime()
        {
            Uri serverIp = new Uri(serverProtAndIp_success, UriKind.Absolute);

            PortableGeneralInterfaceLibraryAsync alpha = new PortableGeneralInterfaceLibraryAsync();

            PortableGeneralInterfaceLibraryAsync.Enum_TimeFormat tf = PortableGeneralInterfaceLibraryAsync.Enum_TimeFormat.DateAndTime;

            var response = alpha.GetSystemTimeAsync(serverIp, tf);

            var replyTime = (from node in response.Result.Descendants("Reply")
                             select new
            {
                Time = node.Element("Time").Value.ToString()
            }).Single();

            DateTime dateTimeOnDevice;

            if (DateTime.TryParseExact(replyTime.Time, "ddd MMM dd,yyyy-hh:mm:ss tt", null, DateTimeStyles.None, out dateTimeOnDevice))
            {
                TimeSpan timeDifference = DateTime.Now - dateTimeOnDevice;

                Assert.IsTrue(timeDifference.Seconds < 5);
            }
            else
            {
                Assert.Inconclusive("could not parse the datetime from the device, so cannot deterime if the times are close");
            }
        }
Example #2
0
        public void Test_canGetSystemTimeResponseAsNotEmptyWithFailingURIAsync_forFormatXMLTV()
        {
            Uri serverIp = new Uri(serverProtAndIp_failure, UriKind.Absolute);

            PortableGeneralInterfaceLibraryAsync alpha = new PortableGeneralInterfaceLibraryAsync();

            PortableGeneralInterfaceLibraryAsync.Enum_TimeFormat tf = PortableGeneralInterfaceLibraryAsync.Enum_TimeFormat.XMLTV;

            var response = alpha.GetSystemTimeAsync(serverIp, tf);

            string result = response.Result.ToString();

            Assert.AreNotEqual("", result);
        }
Example #3
0
        public void Test_canGetSystemTimeResponseFailureCodeWithFailingURIAsync_forFormatDateAndTime()
        {
            Uri serverIp = new Uri(serverProtAndIp_failure, UriKind.Absolute);

            PortableGeneralInterfaceLibraryAsync alpha = new PortableGeneralInterfaceLibraryAsync();

            PortableGeneralInterfaceLibraryAsync.Enum_TimeFormat tf = PortableGeneralInterfaceLibraryAsync.Enum_TimeFormat.DateAndTime;

            var response = alpha.GetSystemTimeAsync(serverIp, tf);

            var successCode = (from node in response.Result.Descendants("Status")
                               select new
            {
                ErrorCode = node.Element("ErrorCode").Value.ToString()
            }).Single();

            Assert.AreEqual("10000", successCode.ErrorCode);
        }