Exemplo n.º 1
0
        public void CreateReport_ZeroCommits_CreatedDictioanaryIsEmpty()
        {
            var reportCreator = new GitReportCreator(moqObject);

            const string testOutput = "";

            var reportHandler = reportCreator.GetReportDictionary(testOutput);

            Assert.Empty(reportHandler);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var newArgs = ManageConsoleArguments(args);

            var gitArgument       = new GitArguments();
            var argumentValidator =
                new ArgumentsValidation(gitArgument, new DirectoryValidation());
            var errorHandler = new GitLogErrors(gitArgument);

            while (!argumentValidator.AreDatesPathValid(newArgs))
            {
                newArgs = errorHandler.FixDatePathError(newArgs);
            }

            IJsonConfig jsonConfig    = new JsonConfig();
            var         processRunner = new GitProcess(gitArgument, jsonConfig);
            var         processOutput = processRunner.RunGitLogProcess();

            var reportHandler = new GitReportCreator(jsonConfig);
            var report        = reportHandler.GetReportDictionary(processOutput);

            var reportPresentation = new GitLogPresentation();

            reportPresentation.PresentReport(report);

            string[] ManageConsoleArguments(string[] arguments)
            {
                var dateHandler     = new DateSinceManager();
                var reportArguments = new string[3];
                var today           = DateTime.Today;

                if (arguments.Length == 2)
                {
                    if (Int32.TryParse(arguments[1], out int parsedString))
                    {
                        var enumFromInt = (FromToday)parsedString;
                        reportArguments[0] = dateHandler.GetDateString(enumFromInt);
                    }
                    reportArguments[1] = today.ToString();
                    reportArguments[2] = arguments[0];
                }
                else
                {
                    reportArguments[0] =
                        dateHandler.GetDateString(FromToday.OneDay);
                    reportArguments[1] = today.ToString();
                    reportArguments[2] = "";
                }
                return(reportArguments);
            }
        }
Exemplo n.º 3
0
        public void CreateReport_MultipleCommits_CreatedDictionaryContainsCorrectValuesUnderConcreteKeys()
        {
            var reportCreator = new GitReportCreator(moqObject);

            const string testOutput = @"divideLine
                                        123
                                        Bruce Lee
                                        05/02/2018
                                        Changes needed
                                        smallLine
                                        33      3       Star/Wars/Ilike.txt
                                        1       2       Common/Knowledge/Start/WhenReady.txt
                                        1       1       Common/Knowledge/Start/Abort.txt
                                        62      5       Computer/IsSlow/Why/Google.txt
                                        divideLine
                                        456
                                        Bruce Leess
                                        05/02/2019
                                        Changes neasdeded
                                        smallLine
                                        33      3       Star/Wars//Ilike.txt
                                        1       2       Common/Knowledge/Start/WhenReady.txt
                                        1       1       Common/Knowledge/Start/Abort.txt
                                        62      5       Computer/IsSlow/Why/Google.txt";

            var reportHandler = reportCreator.GetReportDictionary(testOutput);

            Assert.True(reportHandler.TryGetValue(new HashId
            {
                CommitHash = "123", ComponentId = "Common.Knowledge"
            }, out CommitComponentData testOne));
            Assert.Equal("05/02/2018", testOne.CommitDate);
            Assert.Equal("Bruce Lee", testOne.CommiterName);
            Assert.Equal("Changes needed", testOne.CommitMessage);
            Assert.Equal(2, testOne.ComponentInsertions);
            Assert.Equal(3, testOne.ComponentDeletions);

            Assert.True(reportHandler.TryGetValue(new HashId
            {
                CommitHash = "456", ComponentId = "Computer.Slow"
            }, out CommitComponentData testTwo));
            Assert.Equal("05/02/2019", testTwo.CommitDate);
            Assert.Equal("Bruce Leess", testTwo.CommiterName);
            Assert.Equal("Changes neasdeded", testTwo.CommitMessage);
            Assert.Equal(62, testTwo.ComponentInsertions);
            Assert.Equal(5, testTwo.ComponentDeletions);
        }
Exemplo n.º 4
0
        public void CreateReport_MultipleCommits_CreatedDictionaryContainsCorrectKeys()
        {
            var reportCreator = new GitReportCreator(moqObject);

            const string testOutput = @"divideLine
                                        123
                                        Bruce Lee
                                        05/02/2018
                                        Changes needed
                                        smallLine
                                        33      3       Star/Wars/Ilike.txt
                                        1       2       Common/Knowledge/Start/WhenReady.txt
                                        1       1       Common/Knowledge/Start/Abort.txt
                                        62      5       Computer/IsSlow/Why/Google.txt
                                        divideLine
                                        456
                                        Bruce Leess
                                        05/02/2019
                                        Changes neasdeded
                                        smallLine
                                        33      3       Star/Wars//Ilike.txt
                                        1       2       Common/Knowledge/Start/WhenReady.txt
                                        1       1       Common/Knowledge/Start/Abort.txt
                                        62      5       Computer/IsSlow/Why/Google.txt";

            var reportHandler = reportCreator.GetReportDictionary(testOutput);

            Assert.True(reportHandler.ContainsKey
                            (new HashId {
                CommitHash = "123", ComponentId = "Common.Knowledge"
            }));
            Assert.True(reportHandler.ContainsKey
                            (new HashId {
                CommitHash = "123", ComponentId = "Computer.Slow"
            }));
            Assert.True(reportHandler.ContainsKey
                            (new HashId {
                CommitHash = "456", ComponentId = "Common.Knowledge"
            }));
            Assert.True(reportHandler.ContainsKey
                            (new HashId {
                CommitHash = "456", ComponentId = "Computer.Slow"
            }));
        }