Example #1
0
 public void checkDstDetect()
 {
     Assert.IsTrue(BankHoliday.isDstChangeInBetween(new DateTime(2016, 3, 12), new DateTime(2016, 3, 14)));
     Assert.IsTrue(BankHoliday.isDstChangeInBetween(new DateTime(2016, 11, 6), new DateTime(2016, 11, 7)));
     Assert.IsFalse(BankHoliday.isDstChangeInBetween(new DateTime(2016, 11, 5), new DateTime(2016, 11, 6)));
     Assert.IsFalse(BankHoliday.isDstChangeInBetween(new DateTime(2016, 3, 12), new DateTime(2016, 3, 13)));
 }
        public async Task <IActionResult> Create([Bind("Id,Data,BankHolidaysTypeId")] BankHoliday bankHoliday)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bankHoliday);
                await _context.SaveChangesAsync();

                TempData["Success"] = "Obrigada. O feriado está adicionado com sucesso.";
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BankHolidaysTypeId"] = new SelectList(_context.BankHolidaysType, "Id", "BankHolidayTypeName", bankHoliday.BankHolidaysTypeId);
            return(View(bankHoliday));
        }
Example #3
0
        public void testCloseTime()
        {
            Assert.AreEqual(13, BankHoliday.getCloseTimeForDate(new DateTime(2015, 11, 27)).TotalHours);
            Assert.AreEqual(13, BankHoliday.getCloseTimeForDate(new DateTime(2015, 12, 24)).TotalHours);
            Assert.AreEqual(16, BankHoliday.getCloseTimeForDate(new DateTime(2016, 12, 24)).TotalHours);
            Assert.AreEqual(16, BankHoliday.getCloseTimeForDate(new DateTime(2016, 7, 2)).TotalHours);
            Assert.AreEqual(13, BankHoliday.getCloseTimeForDate(new DateTime(2014, 7, 3)).TotalHours);
            Assert.AreEqual(13, BankHoliday.getCloseTimeForDate(new DateTime(2014, 12, 24)).TotalHours);
            Assert.AreEqual(13, BankHoliday.getCloseTimeForDate(new DateTime(2014, 11, 28)).TotalHours);

            Assert.AreEqual(13, BankHoliday.getCloseTimeForDate(new DateTime(2013, 7, 3)).TotalHours);
            Assert.AreEqual(13, BankHoliday.getCloseTimeForDate(new DateTime(2013, 11, 29)).TotalHours);
            Assert.AreEqual(13, BankHoliday.getCloseTimeForDate(new DateTime(2013, 12, 24)).TotalHours);
        }
Example #4
0
        public void testHolidays()
        {
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 1, 1)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 1, 21)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 2, 18)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 4, 19)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 5, 27)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 7, 4)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 9, 2)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 11, 28)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 12, 25)));


            Assert.IsTrue(BankHoliday.isWorkingDay(new DateTime(2019, 7, 3)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2020, 7, 3)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2021, 7, 5)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2021, 12, 24)));

            Assert.IsTrue(BankHoliday.isWorkingDay(new DateTime(2019, 6, 21)));
            Assert.IsFalse(BankHoliday.isWorkingDay(new DateTime(2019, 6, 22)));
        }
        public void Setup()
        {
            _logger           = new Mock <ILogger <BankHolidayFulfillment> >();
            _applyDataContext = Create.MockedDbContextFor <ApplyDataContext>();
            _govUkApiClient   = new Mock <IGovUkApiClient>();

            _bankHolidayAlreadyPresentInDatabase = new BankHoliday {
                BankHolidayDate = DateTime.Today
            };
            _bankHolidayNotPresentInDatabase = new BankHoliday {
                BankHolidayDate = DateTime.Today.AddDays(1)
            };

            _applyDataContext.Set <BankHoliday>().Add(_bankHolidayAlreadyPresentInDatabase);
            _applyDataContext.SaveChanges();

            _bankHolidayRoot = new BankHolidayRoot
            {
                EnglandAndWales = new BankHolidays
                {
                    Events = new List <Event>
                    {
                        new Event {
                            Date = _bankHolidayAlreadyPresentInDatabase.BankHolidayDate
                        },
                        new Event {
                            Date = _bankHolidayNotPresentInDatabase.BankHolidayDate
                        }
                    }
                }
            };

            _govUkApiClient.Setup(x => x.GetBankHolidays()).ReturnsAsync(_bankHolidayRoot);

            _sut = new BankHolidayFulfillment(_applyDataContext, _logger.Object, _govUkApiClient.Object);
        }
 private void InsertIntoBankHolidaysTable(BankHoliday holiday)
 {
     _context.BankHolidays.Add(holiday);
     _context.SaveChanges();
 }
        public static BankHolidayCollection Populate(DataTable collectionMembers)
        {
            BankHolidayCollection colMembers = new BankHolidayCollection();
            BankHoliday obj = null;

            foreach (DataRow drMember in collectionMembers.Rows)
            {
                obj = new BankHoliday();
                obj.Date = (DateTime)drMember["BankHolidayDate"];
                colMembers.Add(obj);
            }

            return colMembers;
        }
 /// <summary>Gets the <see cref="Calendars.BankHoliday"/> for the given <paramref name="bankHoliday"/>.</summary>
 /// <param name="bankHoliday">The UK bank holiday.</param>
 /// <returns>The <see cref="Calendars.BankHoliday"/>.</returns>
 public Calendars.BankHoliday this[BankHoliday bankHoliday] => this[bankHoliday.ToString()];