示例#1
0
 public void Throw_InvalidID_Exception_if_try_to_change_an_invalid_ID()
 {
     var text = new RepositoryXML(new MemoryStream());
     var activity = new Dictionary<string, string>()
     {
         {"id","12345678" },
         {"project","n/a" },
         {"date","11.11.2015 22:11:20" },
         {"message","Old activity" }
     };
     text.Add(new Activity(activity));
     text.Change("12345677",new Dictionary<string, string> { { "message", "This is the message" } });
 }
示例#2
0
 public void Throw_InvalidFormat_Exception_if_try_to_change_a_date_with_invalid_format_of_date()
 {
     var text = new RepositoryXML(new MemoryStream());
     var activity = new Dictionary<string, string>()
     {
         {"id","12345678" },
         {"project","n/a" },
         {"date","11.11.2015 22:11:20" },
         {"message","Old activity" }
     };
     text.Add(new Activity(activity));
     text.Change("12345678",new Dictionary<string, string> { { "date", "11.12.yyyy" } });
 }
示例#3
0
 public void Repository_change_date_throw_InvalidFormat_Exception_if_date_format_is_not_valid()
 {
     var text = new RepositoryXML(new MemoryStream());
     var activity = new Dictionary<string, string>()
     {
         {"id","12345678" },
         {"project","n/a" },
         {"date","11.12.2015 22:11:2015" },
         {"message","Old activity" }
     };
     text.Add(new Activity(activity));
     text.Change("12345678", new Dictionary<string, string> { { "date", "25.25.2002" } });
 }
示例#4
0
 public string Execute(Arguments arg, Stream stream)
 {
     var change = new StringBuilder();
     change.Append("Change ");
     var repository = new RepositoryXML(stream);
     var modifiedElements = new Dictionary<string, string>();
     foreach (var element in command.Split(' '))
         if (arg[element] != ""&&element.StartsWith("[--"))
         {
             var start = element.IndexOf('<') + 1;
             var end = element.IndexOf('>');
             modifiedElements.Add(element.Substring(start, end - start), arg[element]);
             change.Append($" {element.Substring(start, end - start).ToUpper()}");
         }
     repository.Change(arg["<id>"], modifiedElements);
     return change.ToString();
 }
示例#5
0
 public void Xml_Repository_Activity_Duration_calculation()
 {
     var text = new RepositoryXML(new MemoryStream());
     var activity = new Dictionary<string, string>()
     {
         {"id","12345678" },
         {"project","n/a" },
         {"date","11.11.2015 10:11:00" },
         {"enddate","11.11.2015 10:11:00" },
         {"message","Old activity" }
     };
     text.Add(new Activity(activity));
     var beforStremList = StreamList(text);
     beforStremList.ShouldContain("00h 00m");
     text.Change("12345678", new Dictionary<string, string> { { "enddate", "13.11.2015 10:43:00" } });
     var afterStremList = StreamList(text);
     afterStremList.ShouldContain("2d 00h 32m");
 }
示例#6
0
 public void Xml_Repository_change_date()
 {
     var text = new RepositoryXML(new MemoryStream());
     var activity = new Dictionary<string, string>()
     {
         {"id","12345678" },
         {"project","n/a" },
         {"date","11.11.2015 22:11:25" },
         {"message","Old activity" }
     };
     text.Add(new Activity(activity));
     var beforStremList = StreamList(text);
     beforStremList.ShouldContain("11.11.2015 22:11:25");
     text.Change("12345678", new Dictionary<string, string> { { "date", "09.10.2002 12:11:23" } });
     var afterStremList = StreamList(text);
     afterStremList.ShouldNotContain("11.11.2015 22:11:25");
     afterStremList.ShouldContain("09.10.2002 12:11:23");
 }