Ejemplo n.º 1
0
        public void DeserializeFromTextReader()
        {
            StringReader reader  = new StringReader("<LazyCureData />");
            ITimeLog     timeLog = TimeLogSerializer.Deserialize(reader);

            Assert.IsNotNull(timeLog);
        }
Ejemplo n.º 2
0
        public void CheckSerializedXmlHeader()
        {
            Stub.On(mockTimeLog).GetProperty("Activities").Will(Return.Value(new List <IActivity>()));
            XmlNode xml = TimeLogSerializer.Serialize(mockTimeLog);

            Assert.AreEqual("<?xml version=\"1.0\" standalone=\"yes\"?>", xml.FirstChild.OuterXml);
        }
Ejemplo n.º 3
0
        public void DeserializeCreatesTimeLog()
        {
            XmlDocument xml     = new XmlDocument();
            ITimeLog    timeLog = TimeLogSerializer.Deserialize(xml);

            Assert.IsNotNull(timeLog);
        }
Ejemplo n.º 4
0
        public void TimeLogDateIsSerialized()
        {
            Stub.On(mockTimeLog).GetProperty("Activities").Will(Return.Value(new List <IActivity>()));
            string content = TimeLogSerializer.Serialize(mockTimeLog).InnerXml;

            Assert.IsTrue(content.Contains("2007-02-23"));
        }
Ejemplo n.º 5
0
        public void SerializeAndDeserialize()
        {
            ITimeLog timeLog1 = new TimeLog(DateTime.Now.Date);
            ITimeLog timeLog2 = TimeLogSerializer.Deserialize(TimeLogSerializer.Serialize(timeLog1));

            Assert.AreEqual(timeLog2, timeLog1);
        }
Ejemplo n.º 6
0
        public void VersionIsSerialized()
        {
            Stub.On(mockTimeLog).GetProperty("Activities").Will(Return.Value(new List <IActivity>()));
            XmlNode data    = TimeLogSerializer.Serialize(mockTimeLog)["LazyCureData"];
            Version version = Assembly.GetAssembly(new TimeLogSerializer().GetType()).GetName().Version;

            Assert.AreEqual(version.Major + "." + version.Minor, data.Attributes["LazyCureVersion"].Value);
        }
Ejemplo n.º 7
0
        public void DeserializeSpecifiedTimeLog()
        {
            string sContent = "<?xml version=\"1.0\" standalone=\"yes\"?><LazyCureData><Records>" +
                              "<Activity>changed</Activity><Begin>14:35:02</Begin><Duration>0:00:07</Duration>" +
                              "</Records></LazyCureData>";
            ITimeLog timeLog = TimeLogSerializer.Deserialize(new StringReader(sContent));
            DataRow  row     = timeLog.Data.Rows[0];

            Assert.AreEqual("changed", row["Activity"], "activity name match");
            Assert.AreEqual(DateTime.Parse("14:35:02"), row["Start"], "start match");
            Assert.AreEqual(TimeSpan.Parse("0:00:07"), row["Duration"], "duration match");
        }
Ejemplo n.º 8
0
        public void DateIsDeserialized()
        {
            XmlDocument xml = new XmlDocument();

            xml.InnerXml = "<LazyCureData Date=\"2013-10-14\">" +
                           "<Records>" +
                           "<Activity>first</Activity>" +
                           "</Records>" +
                           "</LazyCureData>";
            ITimeLog timeLog = TimeLogSerializer.Deserialize(xml);

            Assert.AreEqual("2013-10-14", timeLog.Date.ToString("yyyy-MM-dd"));
        }
Ejemplo n.º 9
0
        public void DeserializeTimeLogWithOneActivity()
        {
            XmlDocument xml = new XmlDocument();

            xml.InnerXml = "<LazyCureData>" +
                           "<Records>" +
                           "<Activity>first</Activity>" +
                           "</Records>" +
                           "</LazyCureData>";
            ITimeLog timeLog = TimeLogSerializer.Deserialize(xml);

            Assert.AreEqual(1, timeLog.Activities.Count, "number of activities in TimeLog");
            Assert.AreEqual("first", timeLog.Activities[0].Name);
        }
Ejemplo n.º 10
0
        public void DeserializeOldFormatTimeLog()
        {
            XmlDocument xml = new XmlDocument();

            xml.InnerXml = "<LazyCureData>" +
                           "<Records>" +
                           "<Activity>exercises</Activity>" +
                           "<Begin>PT7H1M</Begin>" +
                           "<Duration>PT9M38S</Duration>" +
                           "</Records>" +
                           "<ActivitiesSummary>" +
                           "<Activity>exercises</Activity>" +
                           "<SpentTime>PT9M38S</SpentTime>" +
                           "</ActivitiesSummary>" +
                           "</LazyCureData>";
            ITimeLog timeLog = TimeLogSerializer.Deserialize(xml);

            Assert.AreEqual(1, timeLog.Activities.Count, "number of activities in TimeLog");
        }
Ejemplo n.º 11
0
        public void SerializeActivities()
        {
            using (Ordered)
            {
                Expect.Once.On(activity).GetProperty("Name").Will(Return.Value("first"));
                Expect.Once.On(activity).GetProperty("Name").Will(Return.Value("second"));
                Expect.Once.On(activity).GetProperty("Name").Will(Return.Value("third"));
            }
            List <IActivity> activities = new List <IActivity>();

            activities.Add(activity);
            activities.Add(activity);
            activities.Add(activity);
            Stub.On(mockTimeLog).GetProperty("Activities").Will(Return.Value(activities));

            string content = TimeLogSerializer.Serialize(mockTimeLog).InnerXml;

            Assert.IsTrue(content.Contains("first"));
            Assert.IsTrue(content.Contains("second"));
            Assert.IsTrue(content.Contains("third"));
        }