Пример #1
0
 public void If_an_element_can_not_be_displayed_wholly_will_end_with_3_points()
 {
     using (var stream = new MemoryStream())
     {
         var command = new Commands(new string[] { "add", "--project:Project Number One and 3 4 5 6", "New Activity" }, stream);
         command.Execute().Equals("Added a new activity");
         ActivitysField(stream, "message").ShouldContain("New Activity");
         ActivitysField(stream, "project").ShouldContain("Project Number One and 3 4 5 6");
         command = new Commands(new string[] { "list" }, stream);
         command.Execute().ShouldNotContain("Project Number One and 3 4 5 6");
         command.Execute().ShouldContain("Project ...");
     }
 }
Пример #2
0
 static void Main(string[] args)
 {
     var path = Directory.GetCurrentDirectory() + @"\Razvan.txt";
     var pathXml = Directory.GetCurrentDirectory() + @"\Razvanss.xml";
     using (var stream = File.Open(pathXml, FileMode.OpenOrCreate))
     {
         try
         {
             var command = new Commands(new ArgumentsConverter(args).Conversion(), stream);
             Console.WriteLine(command.Execute());
         }
         catch (InvalidArgument e)
         {
             Console.WriteLine($"Argument \"{ e.Message}\" is not valid");
             Console.WriteLine(new Help().help);
         }
         catch (ArgumentMissing e)
         {
             Console.WriteLine($"Argument {e.Message}");
             Console.WriteLine(new Help().help);
         }
         catch(RepositoryEmty e)
         {
             Console.WriteLine(e.Message);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
 }
Пример #3
0
 public void Should_add_to_stream_a_new_activity()
 {
     using (var stream = new MemoryStream())
     {
         var command = new Commands(new string[] { "add", "New Activity" }, stream);
         command.Execute().Equals("Added a new activity");
         ActivitysField(stream, "message").ShouldContain("New Activity");
     }
 }
Пример #4
0
 public void Should_add_to_stream_a_new_activity_with_project_label()
 {
     using (var stream = new MemoryStream())
     {
         var command = new Commands(new string[] { "add", "--project:Project Number One", "New Activity" }, stream);
         command.Execute().Equals("Added a new activity");
         ActivitysField(stream, "message").ShouldContain("New Activity");
         ActivitysField(stream, "project").ShouldContain("Project Number One");
     }
 }
Пример #5
0
 public void After_clear_all_activities_command_list_throw_RepositoryEmty_exception()
 {
     using (var stream = new MemoryStream())
     {
         GenerateActivity(stream);
         ActivitysField(stream, "message").ShouldContain("activity1");
         var command = new Commands(new string[] { "clear" }, stream);
         command.Execute().ShouldEqual("Clear all activities");
         command = new Commands(new string[] { "list" }, stream);
         command.Execute();
     }
 }
Пример #6
0
 public void Should_list_the_contents_of_repository()
 {
     using (var stream = new MemoryStream())
     {
         GenerateActivity(stream);
         var command = new Commands(new string[] { "list" }, stream);
         command.Execute().ShouldContain("activity1");
         command.Execute().ShouldContain("activity9");
     }
 }
Пример #7
0
 public void Should_throw_invalid_format_if_the_optional_command_date_is_not_valid_format()
 {
     using (var stream = new MemoryStream())
     {
         var repository = new RepositoryXML(stream);
         var activity = new Dictionary<string, string>
         {
             {"id","12345678" },
             {"project","n/a" },
             {"date","11.12.2015" },
             {"message","Old message" }
         };
         repository.Add(new Activity(activity));
         var command = new Commands(new string[] { "change", "12345678", "--date:date" }, stream);
         command.Execute();
     }
 }
Пример #8
0
        public void Should_list_Activities_from_one_project()
        {
            using (var stream = new MemoryStream())
            {
                var repository = new RepositoryXML(stream);
                var activity = new Dictionary<string, string>()
                {
                    {"id","12345678" },
                    {"project","Razvan" },
                    {"date","11.12.2015" },
                    {"enddate","12.12.2015 " },
                    {"message","First message" }
                };
                var activity1 = new Dictionary<string, string>()
                {
                    {"id","12345678" },
                    {"project","New Project" },
                    {"date","11.12.2015" },
                    {"enddate","11.12.2015 02:19:00" },
                    {"message","Second message" }
                };
                var activity2 = new Dictionary<string, string>()
                {
                    {"id","12345678" },
                    {"project","Razvan" },
                    {"date","11.12.2015" },
                    {"enddate","11.12.2015 03:57:00" },
                    {"message","Third message" }
                };
                repository.Add(new Activity(activity));
                repository.Add(new Activity(activity1));
                repository.Add(new Activity(activity2));
                var command = new Commands(new string[] { "list", "--project:Razvan" }, stream);
                var result = command.Execute();
                result.ShouldContain("First message");
                result.ShouldNotContain("Second Message");
                result.ShouldContain("Third message");

            }
        }
Пример #9
0
 public void Should_throw_invalid_argument_if_optinal_argument_is_not_written_complet()
 {
     using (var stream = new MemoryStream())
     {
         var repository = new RepositoryXML(stream);
         var command = new Commands(new string[] { "add", "--proj", "New message" }, stream);
         command.Execute();
         ActivitysField(stream, "message").ShouldContain("New message");
     }
 }
Пример #10
0
 public void Should_throw_InvalidFormat_exception_if_try_to_change_Enddate_to_be_earlier_than_startDate()
 {
     using (var stream = new MemoryStream())
     {
         var repository = new RepositoryXML(stream);
         var activity = new Dictionary<string, string>()
         {
             {"id","12345678" },
             {"project","n/a" },
             {"date","11.12.2015" },
             {"message","Old message" }
         };
         repository.Add(new Activity(activity));
         var command = new Commands(new string[] { "change", "12345678", "--project:Project OK", "--enddate:10.10.2002", "--message:New message" }, stream);
         command.Execute();
     }
 }
Пример #11
0
 public void Should_throw_exception_RepositoryEmty_if_try_to_list_a_emty_repository()
 {
     var command = new Commands(new string[] { "list" }, new MemoryStream());
     command.Execute();
 }
Пример #12
0
 public void Should_throw_exception_ArgumentMissing_if_an_argument_is_missing()
 {
     var command = new Commands(new string[] { "add" }, new MemoryStream());
     command.Execute();
 }
Пример #13
0
 public void Should_change_activity_date_and_message()
 {
     using (var stream = new MemoryStream())
     {
         GenerateActivity(stream);
         var repository = new RepositoryXML(stream);
         var activity = new Dictionary<string, string>()
         {
             {"id","12345678" },
             {"project","n/a" },
             {"date","11.12.2015" },
             {"message","Old message" }
         };
         repository.Add(new Activity(activity));
         var command = new Commands(new string[] { "change", "12345678", "--date:11.11.1010", "--message:New message" }, stream);
         command.Execute();
         ActivitysField(stream, "date").ShouldContain("11.11.1010 00:00:00");
         ActivitysField(stream, "message").ShouldContain("New message");
     }
 }
Пример #14
0
 public void Should_list_activity_duration()
 {
     using (var stream = new MemoryStream())
     {
         var repository = new RepositoryXML(stream);
         var activity = new Dictionary<string, string>()
         {
             {"id","12345678" },
             {"project","n/a" },
             {"date","11.12.2015" },
             {"enddate","12.12.2015 03:19:00" },
             {"message","Old message" }
         };
         repository.Add(new Activity(activity));
         var command = new Commands(new string[] { "list" }, stream);
         var s = command.Execute();
         command.Execute().ShouldContain("1d 03h 19m");
     }
 }
Пример #15
0
 public void Should_list_the_activity_from_the_last_week()
 {
     using (var stream = new MemoryStream())
     {
         GenerateActivity(stream);
         var repository = new RepositoryXML(stream);
         var date = DateTime.UtcNow.AddDays(-8).ToString();
         var activity = new Dictionary<string, string>()
         {
             {"id","12345678" },
             {"project","n/a" },
             {"date",date },
             {"message","Old message" }
         };
         repository.Add(new Activity(activity));
         activity["date"] = DateTime.UtcNow.ToString();
         activity["message"] = "New Message";
         repository.Add(new Activity(activity));
         var command = new Commands(new string[] { "list", "week" }, stream);
         command.Execute().ShouldContain("New Message");
         command.Execute().ShouldNotContain("Old Message");
     }
 }
Пример #16
0
 public void Should_List_Table_Header_written_with_uppercase()
 {
     using (var stream = new MemoryStream())
     {
         GenerateActivity(stream);
         var repository = new RepositoryXML(stream);
         repository.Add(new Activity("Testing"));
         var command = new Commands(new string[] { "list" }, stream);
         command.Execute().ShouldContain("ID");
         command.Execute().ShouldContain("DATE");
     }
 }
Пример #17
0
 public void Should_list_Projects_duration_and_name()
 {
     using (var stream = new MemoryStream())
     {
         var repository = new RepositoryXML(stream);
         var activity = new Dictionary<string, string>()
         {
             {"id","12345678" },
             {"project","Razvan" },
             {"date","11.12.2015" },
             {"enddate","12.12.2015 " },
             {"message","Old message" }
         };
         var activity1 = new Dictionary<string, string>()
         {
             {"id","12345678" },
             {"project","Razvan" },
             {"date","11.12.2015" },
             {"enddate","11.12.2015 02:19:00" },
             {"message","Old message" }
         };
         var activity2 = new Dictionary<string, string>()
         {
             {"id","12345678" },
             {"project","New Project" },
             {"date","11.12.2015" },
             {"enddate","11.12.2015 03:57:00" },
             {"message","Old message" }
         };
         repository.Add(new Activity(activity));
         repository.Add(new Activity(activity1));
         repository.Add(new Activity(activity2));
         var command = new Commands(new string[] { "list","projects" }, stream);
         var result = command.Execute();
         result.ShouldContain("1d 02h 19m");
         result.ShouldContain("Razvan");
         result.ShouldContain("03h 57m");
         result.ShouldContain("New Project");
     }
 }
Пример #18
0
 public void Should_show_the_help_message()
 {
     using (var stream = new MemoryStream())
     {
         GenerateActivity(stream);
         var repository = new RepositoryXML(stream);
         var command = new Commands(new string[] { "help" }, stream);
         command.Execute().ShouldContain("list [week]");
         command.Execute().ShouldContain("add");
     }
 }
Пример #19
0
 public void Should_clear_all_activities()
 {
     using (var stream = new MemoryStream())
     {
         GenerateActivity(stream);
         ActivitysField(stream, "message").ShouldContain("activity1");
         var command = new Commands(new string[] { "clear" }, stream);
         command.Execute().ShouldEqual("Clear all activities");
     }
 }