Esempio n. 1
0
        public void Can_Deserialize_Fat()
        {
            string content      = File.ReadAllText(SampleData.PathFor("Fat.txt"));
            var    deserializer = new RestSharp.Deserializers.XmlDeserializer();

            deserializer.RootElement = "fat";

            Fat result = deserializer.Deserialize <Fat>(new RestResponse()
            {
                Content = content
            });

            Assert.IsNotNull(result);
            Assert.IsTrue(result.FatLogs.Count == 2);

            FatLog log = result.FatLogs[0];

            Assert.AreEqual(log.LogId, 1330991999000);
            Assert.AreEqual(log.Date, new DateTime(2012, 3, 5));
            Assert.AreEqual(log.Time, new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59));
            Assert.AreEqual(log.Fat, 14);
            Assert.AreEqual(log.DateTime, new DateTime(2012, 3, 5, 23, 59, 59));

            log = result.FatLogs[1];
            Assert.AreEqual(log.LogId, 1330991999000);
            Assert.AreEqual(log.Date, new DateTime(2012, 3, 5));
            Assert.AreEqual(log.Time, new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 21, 20, 59));
            Assert.AreEqual(log.Fat, 13.5);
            Assert.AreEqual(log.DateTime, new DateTime(2012, 3, 5, 21, 20, 59));
        }
Esempio n. 2
0
        private void ValidateFat(Fat fat)
        {
            Assert.IsNotNull(fat);

            Assert.AreEqual(2, fat.FatLogs.Count);

            FatLog log = fat.FatLogs.First();

            Assert.IsNotNull(log);

            Assert.AreEqual(new DateTime(2012, 3, 5), log.Date);
            Assert.AreEqual(1330991999000, log.LogId);
            Assert.AreEqual(14, log.Fat);
            Assert.AreEqual(new DateTime(2012, 3, 5, 23, 59, 59).TimeOfDay, log.Time.TimeOfDay);

            fat.FatLogs.Remove(log);
            log = fat.FatLogs.First();

            Assert.IsNotNull(log);

            Assert.AreEqual(new DateTime(2012, 3, 5), log.Date);
            Assert.AreEqual(1330991999000, log.LogId);
            Assert.AreEqual(13.5, log.Fat);
            Assert.AreEqual(new DateTime(2012, 3, 5, 21, 20, 59).TimeOfDay, log.Time.TimeOfDay);
        }
Esempio n. 3
0
        public void FatLog_DateTime_Mash()
        {
            var date   = new DateTime(2014, 10, 2);
            var time   = new DateTime(1970, 1, 1, 12, 45, 56);
            var fatlog = new FatLog();

            fatlog.Date = date;
            fatlog.Time = time;

            Assert.AreEqual(new DateTime(2014, 10, 2, 12, 45, 56), fatlog.DateTime);
        }
Esempio n. 4
0
        public void Retrieve_Fat_Last_Week()
        {
            DateTime startDate = DateTime.Now.AddDays(-7);
            DateTime endDate   = DateTime.Now;
            Fat      fat       = client.GetFat(startDate, endDate);

            Assert.IsNotNull(fat);
            Assert.IsNotNull(fat.FatLogs);

            Assert.IsTrue(fat.FatLogs.Count > 0);
            FatLog firstFat = fat.FatLogs[0];

            Assert.GreaterOrEqual(firstFat.DateTime, startDate.Date);
            Assert.Less(firstFat.DateTime, endDate.AddDays(1).Date);
            Assert.IsTrue(firstFat.LogId > 0);
            Assert.IsTrue(firstFat.Fat > 0);
        }