示例#1
0
        public async Task ImportAsync_MustImportStatesFromCsvFile_True(string file)
        {
            // Arrange
            string filename = Helper.GetFilePath(file);
            IImportStateService stateService = Helper.GetImportStateService();

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

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

            if (result.Success)
            {
                List <List <State> > states = (List <List <State> >)result.Data;
                Assert.NotNull(states);
                Assert.True(states.Count > 0);
                for (int i = 0, j = states.Count; i < j; i++)
                {
                    Assert.True(states[i].Count > 0);
                }
            }
        }
示例#2
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));
 }
示例#3
0
        public static IImportStateService GetImportStateService()
        {
            if (_importStateService == null)
            {
                var notificationHandler = GetNotificationHandler();
                var unitOfWork          = GetUnitOfWorkCore();
                var addStateService     = GetAddStateService();
                var userLogged          = GetUserLogged();

                _importStateService = new ImportStateService(notificationHandler, unitOfWork, userLogged, addStateService);
            }

            return(_importStateService);
        }
示例#4
0
        public async Task ImportAsync_MustImportStatesFromCsvFile_False(string file)
        {
            // Arrange
            string filename = Helper.GetFilePath(file);
            IImportStateService stateService = Helper.GetImportStateService();

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

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