public void MonthToDays_GivenMonth_ReturnDaysInMonth(string month, int expected) { // Arrange var daysInMonth = new DaysInMonth(); // Act var result = daysInMonth.MonthToDays(month); // Assert result.Should().Be(expected); }
public override int GetHashCode() { unchecked { int hashCode = Years.GetHashCode(); hashCode = (hashCode * 397) ^ Months.GetHashCode(); hashCode = (hashCode * 397) ^ Days.GetHashCode(); hashCode = (hashCode * 397) ^ Hours.GetHashCode(); hashCode = (hashCode * 397) ^ Minutes.GetHashCode(); hashCode = (hashCode * 397) ^ Seconds.GetHashCode(); hashCode = (hashCode * 397) ^ Milliseconds.GetHashCode(); hashCode = (hashCode * 397) ^ DaysInMonth.GetHashCode(); return(hashCode); } }
private IEnumerable <WorkPatternRepresentation> CombineWeeklyPatternsIntoMonthlyOnes( List <WorkPatternRepresentation> weeklyPatterns) { DaysInMonth.ToString(); WorkdaysInMonth.ToString(); var patternValidator = new WorkPatternValidator(new List <BusinessRule>()); var monthlyPatterns = new List <WorkPatternRepresentation>(); var random = new Random(); foreach (var weeklyPattern in weeklyPatterns) { var monthlyPattern = weeklyPattern; // just consider 5 weekly patterns will cover the month // (normally, we should find the first multiple of 5 larger than WorkDaysInMonth) // TODO the Times() extension method would be useful here for (var count = 0; count < 5; count += 1) { var randomIndex = random.Next(0, weeklyPatterns.Count); var randomNextPattern = weeklyPatterns.ElementAt(randomIndex); var candidateForExtendedPattern = new WorkPatternRepresentation( monthlyPattern.Concat(randomNextPattern)); while (!patternValidator.Validate(candidateForExtendedPattern)) { randomIndex = random.Next(0, weeklyPatterns.Count); randomNextPattern = weeklyPatterns.ElementAt(randomIndex); candidateForExtendedPattern = new WorkPatternRepresentation( monthlyPattern.Concat(randomNextPattern)); } // TODO as a safety measure, the above loop should be forcefully // exited if it has been looping for a large number of times monthlyPattern = candidateForExtendedPattern; } monthlyPatterns.Add(monthlyPattern); } return(monthlyPatterns); }
public void beforeTest() { dim = new DaysInMonth(); }