public void GetRecordListByProjectWithSortAndNoProjectIdSpecification_IntegrationTest_Error_MixedValidInValidRecords()
        {
            // Arrange
            int  project           = 0; // This means no project i specified as per the CommandLine nuget package. Hence all records code is being invoked.
            bool isSortByStartDate = true;

            string           fileFullPath     = Path.Join(_applicationBase, @"TestData\MixedExampleData.tsv");
            FileParserClient fileParserClient = new FileParserClient();
            IFileParser      iFileParser      = fileParserClient.GetFileParserFromFileExtension(fileFullPath);
            FileParserFacade fileParserFacade = new FileParserFacade(iFileParser);

            // Act
            List <Record> records = project == 0 ?
                                    (isSortByStartDate ? fileParserFacade.GetRecordList().OrderBy(s => s.StartDate).ToList() : fileParserFacade.GetRecordList().ToList()) :
                                    (isSortByStartDate ? fileParserFacade.GetRecordListByProject(project).OrderBy(s => s.StartDate).ToList() : fileParserFacade.GetRecordListByProject(project).ToList());


            List <Record> faultyRecords = records.Where(s => !string.IsNullOrWhiteSpace(s.Error)).ToList();

            // Assert
            Assert.IsNotNull(records);
            Assert.AreEqual(9, records.Count);
            Assert.IsNotNull(faultyRecords);
            Assert.AreEqual(5, faultyRecords.Count);
        }
Esempio n. 2
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        static void Main(string[] args)
        {
            // PreValidate arguments
            List <string> arguments = PreValidateArguments(args);

            // Try to parse the passed arguments. In-case of invalid one, it should show proper message with example
            var commandLineParser = new Parser(c =>
            {
                c.CaseSensitive = false;
                c.HelpWriter    = System.Console.Error;
            });

            commandLineParser.ParseArguments <Options>(arguments)
            .WithParsed <Options>(o =>
            {
                try
                {
                    // In case of any invalid file path,
                    if (!File.Exists(o.Filename))
                    {
                        StringUtilities.DisplayMessage($"File : {o.Filename} does not exists! Please specify a valid file full name along with the path.");
                        Environment.Exit(0);
                    }

                    // Register services for dependency injection
                    Bootstrapper.Instance.RegisterServices();

                    #region Record Retrieval as per filter if any

                    FileParserClient fileParserClient = new FileParserClient();
                    IFileParser iFileParser           = fileParserClient.GetFileParserFromFileExtension(o.Filename);
                    FileParserFacade fileParserFacade = new FileParserFacade(iFileParser);
                    List <Record> records             = o.Project == 0 ?
                                                        (o.IsSortByStartDate ? fileParserFacade.GetRecordList().OrderBy(s => s.StartDate).ToList() : fileParserFacade.GetRecordList().ToList()) :
                                                        (o.IsSortByStartDate ? fileParserFacade.GetRecordListByProject(o.Project).OrderBy(s => s.StartDate).ToList() : fileParserFacade.GetRecordListByProject(o.Project).ToList());

                    #endregion

                    // Display header
                    DisplayHeader(fileParserFacade.FileHeaderColumns);

                    // Display records
                    DisplayRecords(fileParserFacade.FileHeaderColumns, records);

                    // Dispose services
                    fileParserClient.Dispose();
                    Bootstrapper.Instance.DisposeServices();
                }
                catch (Exception ex)
                {
                    StringUtilities.DisplayMessage(StringUtilities.GetMessageFromException(ex));
                }
            })
            .WithNotParsed <Options>(o =>
            {
                // Automatically help section should display.
            });
        }
        public void GetRecordListByProjectWithSort_IntegrationTest_Error_MixedValidInValidRecords()
        {
            // Arrange
            int project = 6;

            string           fileFullPath     = Path.Join(_applicationBase, @"TestData\MixedExampleData.tsv");
            FileParserClient fileParserClient = new FileParserClient();
            IFileParser      iFileParser      = fileParserClient.GetFileParserFromFileExtension(fileFullPath);
            FileParserFacade fileParserFacade = new FileParserFacade(iFileParser);

            // Act
            List <Record> records = fileParserFacade.GetRecordListByProject(project).OrderBy(s => s.StartDate).ToList();

            List <Record> faultyRecords = records.Where(s => !string.IsNullOrWhiteSpace(s.Error)).ToList();

            // Assert
            Assert.IsNotNull(records);
            Assert.AreEqual(3, records.Count);
            Assert.IsNotNull(faultyRecords);
            Assert.AreEqual(1, faultyRecords.Count);
        }
Esempio n. 4
0
        public void Setup()
        {
            _fileName = "ExampleData.tsv";

            _fileParserClient = new FileParserClient();
        }