public void IsWeekend_RealLogic_Friday_False() { var service = new DayOfWeekService(); var friday = new DateTime(2020, 10, 02); var actual = service.IsWeekend(friday); actual.Should().Be(false); }
public void IsWeekend_RealLogic_Saturday_True() { var service = new DayOfWeekService(); var saturday = new DateTime(2020, 10, 03); var actual = service.IsWeekend(saturday); actual.Should().Be(true); }
public void IsWeekend_Monday_False() { const bool expected = false; var service = new DayOfWeekService(); var monday = new DateTime(2020, 10, 02); var actual = service.IsWeekend(monday); actual.Should().Be(expected); }
public void IsWeekend_Sunday_True() { var service = new DayOfWeekService(); const bool expected = true; var sunday = new DateTime(2020, 10, 03); var actual = service.IsWeekend(sunday); actual.Should().Be(expected); }
public void GetNotWeekend() { // Arrange var thisSunday = new DateTime(2020, 10, 05); var service = new DayOfWeekService(); // Act var result = service.IsWeekend(thisSunday); // Assert result.Should().Be(false); }
public void SetUp() { IDayOfWeekService dayOfWeekService = new DayOfWeekService(); service = new DayShiftService(dayOfWeekService); }
public void Setup() { _dayOfWeekService = new DayOfWeekService(); }
static void Main(string[] args) { IDayOfWeek dow; IStringCharacters sc; IRemainder r; IDateFromOffset dfo; string firstDate; string secondDate; int num; int denom; int rem; string newDate; Console.WriteLine("Test 1: 10/10/2018 and 10/12/2018 Return 10/13/2018"); Console.WriteLine("Hit ENTER to run the test"); Console.ReadLine(); //Test 1 dow = new DayOfWeekService(); sc = new StringCharacterService(); r = new RemainderService(); dfo = new DateFromOffsetService(); try { firstDate = dow.GetDayOfWeek("10/10/2018"); Debug.Assert(firstDate == "Wednesday"); secondDate = dow.GetDayOfWeek("10/12/2018"); Debug.Assert(secondDate == "Friday"); num = sc.CountVowelsInString(firstDate); Debug.Assert(num == 3); denom = sc.CountVowelsInString(secondDate); Debug.Assert(denom == 2); rem = r.FindRemainder(num, denom); Debug.Assert(rem == 1); newDate = dfo.GetDateFromOffset("10/12/2018", rem); Debug.Assert(newDate == "10/13/2018"); Console.WriteLine($"WooHoo!!! New date: '{newDate}'"); Console.WriteLine(); } catch (Exception e) { Console.WriteLine("BOOM!!! Exception encountered..."); Console.WriteLine(e); } // Test 2 Console.ReadLine(); Console.WriteLine("Test 2: Let's test some edge cases"); Console.WriteLine(); // Parsing Tests try { Console.WriteLine("Hit ENTER to test parsing by passing an empty string..."); Console.ReadLine(); dow = new DayOfWeekService(); // Passing an empty string var result = dow.GetDayOfWeek(""); Console.WriteLine($"Passing an empty string for the date returns '{result}'"); Console.WriteLine(); } catch (Exception e) { Console.WriteLine("BOOM!!! Exception encountered..."); Console.WriteLine(e); } // String Character Tests try { Console.ReadLine(); Console.WriteLine("Hit ENTER to test string characters by passing a null..."); Console.ReadLine(); sc = new StringCharacterService(); // Passing a null value var result = sc.CountVowelsInString(null); Console.WriteLine($"Passing null value for the string returns {result}"); Console.WriteLine(); } catch (Exception e) { Console.WriteLine("BOOM!!! Exception encountered..."); Console.WriteLine(e); } try { Console.ReadLine(); Console.WriteLine("Hit ENTER to test string characters by passing a mixed-case string..."); Console.ReadLine(); sc = new StringCharacterService(); // Passing a null value var result = sc.CountVowelsInString("AaBbCcDdEe"); Debug.Assert(result == 4); Console.WriteLine($"Passing 'AaBbCcDdEe' value for the string returns {result}"); Console.WriteLine(); } catch (Exception e) { Console.WriteLine("BOOM!!! Exception encountered..."); Console.WriteLine(e); } // Math Tests try { Console.ReadLine(); Console.WriteLine("Hit ENTER to test math by passing 0 for denominator..."); Console.ReadLine(); r = new RemainderService(); // Passing a 0 for the denominator var result = r.FindRemainder(1, 0); Console.WriteLine($"Passing 0 for the denominator returns {result}"); Console.WriteLine(); } catch (Exception e) { Console.WriteLine("BOOM!!! Exception encountered..."); Console.WriteLine(e); } // Date Tests try { Console.ReadLine(); Console.WriteLine("Hit ENTER to test date by passing an invalid date string..."); Console.ReadLine(); dfo = new DateFromOffsetService(); // Passing invalid string for date var result = dfo.GetDateFromOffset("blah", 0); Console.WriteLine($"Passing invalid date string returns '{result}'"); Console.WriteLine(); } catch (Exception e) { Console.WriteLine("BOOM!!! Exception encountered..."); Console.WriteLine(e); } Console.WriteLine("All Done! Hit ENTER to quit"); Console.ReadLine(); }