public async Task ImportAsync_MustImportRulesHolidaysFromCsvFile_True(string file)
        {
            // Arrange
            string filename = Helper.GetFilePath(file);
            IImportRuleHolidayService ruleHolidayService = Helper.GetImportRuleHolidayService();

            //
            // Act
            //
            var result = await ruleHolidayService.ImportAsync(filename);

            // Assert
            Assert.True(result.Success);

            if (result.Success)
            {
                List <List <RuleHoliday> > rulesHolidays = (List <List <RuleHoliday> >)result.Data;
                Assert.NotNull(rulesHolidays);
                Assert.True(rulesHolidays.Count > 0);
                for (int i = 0, j = rulesHolidays.Count; i < j; i++)
                {
                    Assert.True(rulesHolidays[i].Count > 0);
                }
            }
        }
 /// <summary>
 /// Return a instance of <see cref="ImportsController"/>.
 /// </summary>
 /// <param name="notificationHandler">For handling error notification messages.</param>
 /// <param name="importCountryService">To import countries to database.</param>
 /// <param name="importStateService">To import states to database.</param>
 /// <param name="importRuleHolidayService">To import rules holidays to database.</param>
 /// <param name="logger">For handling logging application errors.</param>
 public ImportsController(INotificationHandler notificationHandler,
                          IImportCountryService importCountryService,
                          IImportStateService importStateService,
                          IImportRuleHolidayService importRuleHolidayService) : base(notificationHandler)
 {
     _importCountryService     = importCountryService ?? throw new ArgumentNullException(nameof(importCountryService));
     _importStateService       = importStateService ?? throw new ArgumentNullException(nameof(importStateService));
     _importRuleHolidayService = importRuleHolidayService ?? throw new ArgumentNullException(nameof(importRuleHolidayService));
 }
Beispiel #3
0
        public static IImportRuleHolidayService GetImportRuleHolidayService()
        {
            if (_importRuleHolidayService == null)
            {
                var notificationHandler   = GetNotificationHandler();
                var unitOfWork            = GetUnitOfWorkCore();
                var addRuleHolidayService = GetAddRuleHolidayService();
                var userLogged            = GetUserLogged();

                _importRuleHolidayService = new ImportRuleHolidayService(notificationHandler, unitOfWork, userLogged, addRuleHolidayService);
            }

            return(_importRuleHolidayService);
        }
        public async Task ImportAsync_MustImportRulesHolidaysFromCsvFile_False(string file)
        {
            // Arrange
            string filename = Helper.GetFilePath(file);
            IImportRuleHolidayService ruleHolidayService = Helper.GetImportRuleHolidayService();

            //
            // Act
            //
            var result = await ruleHolidayService.ImportAsync(filename);

            // Assert
            Assert.False(result.Success);
        }