コード例 #1
0
        static void Main(string[] args)
        {
            var dataLoader             = new CsvDataLoader();
            var dateProcessor          = new DateProcessor();
            var dataAggregator         = new DataAggregator();
            var dataExporter           = new CsvDataExporter();
            var excelReader            = new ExcelDataLoader();
            var csvFinancialDataLoader = new CsvFinancialDataLoader();

            var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            var result        = dataLoader.LoadDataFromFile(desktopFolder + "/Diplomovka_ESF/transformed_10000.csv");
            // var result = dataLoader.LoadDataFromFile(desktopFolder + "/Diplomovka_ESF/owners.csv");

            List <BusinessDataItem> parsedBusinessData = new List <BusinessDataItem>();

            result.ForEach(res => parsedBusinessData.AddRange(dateProcessor.SplitBusinessDataByYear(res)));

            var allLoadedIcos            = parsedBusinessData.Select(businessData => businessData.ICO).Distinct().OrderBy(ico => ico).ToList();
            var allIcosWithFinancialData = excelReader.LoadFinancialDataOfCompany(allLoadedIcos, desktopFolder + "/Data_DP/financial_data.xlsx");

            Console.WriteLine($"AllLoadedIcos size {allLoadedIcos.Count} vs. icos with financialData size {allIcosWithFinancialData.Count}");

            // var allIcosWithFinancialData = csvFinancialDataLoader.LoadFinancialDataOfCompany(allLoadedIcos, desktopFolder + "/Data_DP/financial_data_less_detail.csv");
            // Console.WriteLine($"AllLoadedIcos size {allLoadedIcos.Count} vs. icos with financialData from csv size {allIcosWithFinancialData.Count}");

            List <CompanyOutputData> ownersInfo = dataAggregator.AggregateDataByCompany(parsedBusinessData);

            dataExporter.ExportDataToCsv(ownersInfo);

            Console.WriteLine("Transformation finished");
        }
コード例 #2
0
        public void SplitBusinessDataByYears_MoreYears()
        {
            var inputBusinessItem = new BusinessDataItem
            {
                ICO              = "123",
                Name             = "Test company",
                LegalFormOfOwner = "s.r.o",
                CountryOfOwner   = "Czech republic",
                OwnerCountrySign = "DOM",
                OwnerType        = "FO",
                OwnerShare       = "50",
                FromTime         = DateTime.ParseExact("01.07.2015", "dd.MM.yyyy", CultureInfo.CurrentCulture),
                ToTime           = DateTime.ParseExact("30.09.2021", "dd.MM.yyyy", CultureInfo.CurrentCulture),
                IsValid          = "1",
            };

            var dateProcessor = new DateProcessor();
            var result        = dateProcessor.SplitBusinessDataByYear(inputBusinessItem);

            Assert.AreEqual(7, result.Count);

            Assert.AreEqual(DateTime.ParseExact("01.07.2015", "dd.MM.yyyy", CultureInfo.CurrentCulture), result[0].FromTime);
            Assert.AreEqual(DateTime.ParseExact("31.12.2015", "dd.MM.yyyy", CultureInfo.CurrentCulture), result[0].ToTime);

            Assert.AreEqual(DateTime.ParseExact("01.01.2021", "dd.MM.yyyy", CultureInfo.CurrentCulture), result[6].FromTime);
            Assert.AreEqual(DateTime.ParseExact("30.09.2021", "dd.MM.yyyy", CultureInfo.CurrentCulture), result[6].ToTime);
        }
コード例 #3
0
        public void GetLastSundayForEachMonth_GivenYear2013_ShouldReturnLastSundayDateForEachMonth()
        {
            //Arrange
            var       sut      = new DateProcessor();
            const int year     = 2013;
            var       expected = new List <DateTime>()
            {
                new DateTime(year, 1, 27),
                new DateTime(year, 2, 24),
                new DateTime(year, 3, 31),
                new DateTime(year, 4, 28),
                new DateTime(year, 5, 26),
                new DateTime(year, 6, 30),
                new DateTime(year, 7, 28),
                new DateTime(year, 8, 25),
                new DateTime(year, 9, 29),
                new DateTime(year, 10, 27),
                new DateTime(year, 11, 24),
                new DateTime(year, 12, 29)
            };

            //Act
            var actual = sut.GetLastSundayForEachMonth(year);

            //Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void GetLastSundayForEachMonth_GivenYear2013_ShouldReturnFirstdateOfEachMonth()
        {
            //Arrange
            var sut      = new DateProcessor();
            var year     = 2013;
            var expected = new List <DateTime>()
            {
                new DateTime(year, 1, 1),
                new DateTime(year, 2, 1),
                new DateTime(year, 3, 1),
                new DateTime(year, 4, 1),
                new DateTime(year, 5, 1),
                new DateTime(year, 6, 1),
                new DateTime(year, 7, 1),
                new DateTime(year, 8, 1),
                new DateTime(year, 9, 1),
                new DateTime(year, 10, 1),
                new DateTime(year, 11, 1),
                new DateTime(year, 12, 1)
            };

            //Act
            var actual = sut.GetLastSundayForEachMonth(year);

            //Assert
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public Workout ProcessWorkout(string serializedWorkout)
        {
            var workoutComponents = WorkoutSplicer.SplitWorkoutComponents(serializedWorkout);

            return(new Workout
            {
                Date = DateProcessor.ProcessDate(workoutComponents.date),
                Weight = WeightProcessor.ProcessWeight(workoutComponents.weight),
                Exercises = ExerciseProcessor.ProcessExercises(workoutComponents.exercises)
            });
        }
コード例 #6
0
        public void GetLastSundayForEachMonth_GivenYear2013_ShouldReturnNumberOfMonths()
        {
            //Arrange
            var sut      = new DateProcessor();
            var year     = 2013;
            var expected = 12;

            //Act
            var actual = sut.GetLastSundayForEachMonth(year);

            //Assert
            Assert.AreEqual(expected, actual.Count);
        }
コード例 #7
0
        //[Ignore("Check it later")]
        public void GetLastSundayForEachMonth_GivenYear2013_ShouldReturnYear()
        {
            //Arrange
            var sut      = new DateProcessor();
            var year     = 2013;
            var expected = 2013;

            //Act
            var actual = sut.GetLastSundayForEachMonth(year);

            //Assert
            Assert.AreEqual(expected, actual.FirstOrDefault().Year);
        }