public void Creates_When_WeekStart_Is_Valid_Value(DateTime weekStart) { //Arrange & Act var sut = new WeekStart(weekStart); //Assert sut.Value.Should().Be(weekStart); }
public CurrentDates() { Today = DateTime.Today; MonthStart = new DateTime(Today.Year, Today.Month, 1); MonthEnd = MonthStart.AddMonths(1); DayOfWeek day = DateTime.UtcNow.DayOfWeek; int days = day - DayOfWeek.Monday; WeekStart = DateTime.UtcNow.AddDays(-days); WeekEnd = WeekStart.AddDays(6); }
public void Fails_When_WeekStart_Is_Default_DateTime() { //Arrange DateTime weekStart = default; //Act Action action = () => { var sut = new WeekStart(weekStart); }; //Assert action.Should().Throw <ArgumentException>(); }
/// <summary> /// Converts a WeekStart value to a corresponding string value /// </summary> /// <param name="enumValue">The WeekStart value to convert</param> /// <returns>The representative string value</returns> public static string ToValue(WeekStart enumValue) { switch (enumValue) { //only valid enum elements can be used //this is necessary to avoid errors case WeekStart.MONDAY: case WeekStart.TUESDAY: case WeekStart.WEDNESDAY: case WeekStart.THURSDAY: case WeekStart.FRIDAY: case WeekStart.SATURDAY: case WeekStart.SUNDAY: return(StringValues[(int)enumValue]); //an invalid enum value was requested default: return(null); } }
private async Task SelectPreviousWeekAsync() { DateTime dayOnPreviousWeek = WeekStart.AddDays(-1); await SetWeekByDayAsync(dayOnPreviousWeek); }