public void DateOnWeekend_IsTrue()
            {
                DateTime date = new DateTime(2015, 11, 1); // Sunday
                Assert.True(date.IsWeekend());

                date = new DateTime(2015, 11, 7);
                Assert.True(date.IsWeekend());
            }
 public void IsWeekendTest()
 {
     DateTime dt = new DateTime(2015, 5, 2);
     Assert.True(dt.IsWeekend());
     dt = new DateTime(2015, 5, 3);
     Assert.True(dt.IsWeekend());
     for (int i = 0; i < 5; i++)
     {
         dt = new DateTime(2015, 5, 4 + i);
         Assert.False(dt.IsWeekend());
     }
 }
        public void Listing_7_5()
        {
            DateTime importantDate = new DateTime(2011, 5, 7);

            if (importantDate.IsWeekend())
            {
                WeekendProcessing();
            }
            else
            {
                WeekdayProcessing();
            }
        }
        public void IsWeekend_WithWeekendDayDate_ExpectTrue(
            int year,
            int month,
            int day,
            DayOfWeek expectedDayOfWeek)
        {
            // Arrange
            DateTimeExtensions.MinValid = new DateTime(year, 1, 1);
            DateTimeExtensions.MaxValid = new DateTime(year, 12, 31);

            var classUnderTest = new DateTime(year, month, day, 23, 53, 59);

            Assert.AreEqual(expectedDayOfWeek, classUnderTest.DayOfWeek);

            // Act
            var actual = classUnderTest.IsWeekend();

            // Assert
            Assert.AreEqual(true, actual);
        }
 public void SundayTest()
 {
     var lastSunday = new DateTime(2014, 4, 27); // known Sunday
     lastSunday.IsWeekend().ShouldBeTrue();
 }
 public void MondayTest()
 {
     var today = new DateTime(2014, 4, 28); //known Monday
     today.IsWeekend().ShouldBeFalse();
 }
        public void IsWeekendTest()
        {
            var sunday = new DateTime(2012, 4, 1);
            Assert.AreEqual(DayOfWeek.Sunday, sunday.DayOfWeek);
            Assert.IsTrue(sunday.IsWeekend());

            var monday = sunday.AddDays(1);
            Assert.AreEqual(DayOfWeek.Monday, monday.DayOfWeek);
            Assert.IsFalse(monday.IsWeekend());

            var tuesday = sunday.AddDays(2);
            Assert.AreEqual(DayOfWeek.Tuesday, tuesday.DayOfWeek);
            Assert.IsFalse(tuesday.IsWeekend());

            var wednesday = sunday.AddDays(3);
            Assert.AreEqual(DayOfWeek.Wednesday, wednesday.DayOfWeek);
            Assert.IsFalse(wednesday.IsWeekend());

            var thursday = sunday.AddDays(4);
            Assert.AreEqual(DayOfWeek.Thursday, thursday.DayOfWeek);
            Assert.IsFalse(thursday.IsWeekend());

            var friday = sunday.AddDays(5);
            Assert.AreEqual(DayOfWeek.Friday, friday.DayOfWeek);
            Assert.IsFalse(friday.IsWeekend());

            var saturday = sunday.AddDays(6);
            Assert.AreEqual(DayOfWeek.Saturday, saturday.DayOfWeek);
            Assert.IsTrue(saturday.IsWeekend());
        }
        public void IsWorkdayShouldSuccessWhenHolydayCalculatorsIsNullAndDayIsNotWeekend()
        {
            var year = 2012;
            var monday = new DateTime(year, 4, 2);
            Assert.AreEqual(DayOfWeek.Monday, monday.DayOfWeek);

            var mondayIsWeekend = monday.IsWeekend();
            var mondayIsWorkday = monday.IsWorkDay(null);

            Assert.False(mondayIsWeekend);
            Assert.True(mondayIsWorkday);
        }
 public void Should_DefineWeekend_WhenCalledOn(DateTime date, bool isWeekend)
 {
     date.IsWeekend().Should().Be(isWeekend);
 }
Example #10
0
 public bool GoLife(DateTime date)
 {
     if (date.IsWeekend()) {
         Rest ();
         return true;
     } else {
         return false;
     }
 }
        public void Should_check_is_weekend()
        {
            //arrange
            var date1 = new DateTime(2013, 03, 30, 0, 0, 0);
            var date2 = new DateTime(2013, 03, 28, 0, 0, 0);

            //act
            var res1 = date1.IsWeekend();
            var res2 = date2.IsWeekend();

            //assert
            res1.Should().BeTrue();
            res2.Should().BeFalse();
        }
            public void Yes()
            {
                var saturday = new DateTime(2015, 11, 7);
                saturday.IsWeekend().Should().BeTrue();

                var sunday = new DateTime(2015, 11, 8);
                sunday.IsWeekend().Should().BeTrue();
            }
            public void No()
            {
                var monday = new DateTime(2015, 11, 2);
                monday.IsWeekend().Should().BeFalse();

                var tuesday = new DateTime(2015, 11, 3);
                tuesday.IsWeekend().Should().BeFalse();

                var wednsdey = new DateTime(2015, 11, 3);
                wednsdey.IsWeekend().Should().BeFalse();

                var thursday = new DateTime(2015, 11, 3);
                thursday.IsWeekend().Should().BeFalse();

                var friday = new DateTime(2015, 11, 3);
                friday.IsWeekend().Should().BeFalse();
            }
 public void TestIsWeekendSunTrue()
 {
     var date = new DateTime(2015, 8, 23);
     Assert.IsTrue(date.IsWeekend());
 }
 public void TestIsWeekendThursdayFalse()
 {
     var date = new DateTime(2015, 8, 20);
     Assert.IsFalse(date.IsWeekend());
 }
 public void MoveTo(int inquiryId, DateTime date)
 {
     var inquiry = repository.Get<Inquiry>(inquiryId);
     if (inquiry == null || date.IsWeekend())
     {
         throw new ModelIsNotValidException();
     }
     inquiry.ReferenceDate = date;
     repository.Save(inquiry);
 }