public void Read_Should_ReturnNoGroups_When_ProvidedXmlWithMissingElement() { // Arrange File.Copy("TestConfigurations\\InValidConfig.xml", "conf\\invalid.xml"); var reader = new ConfigurationFileReader(); // Act var groups = reader.Read("conf\\invalid.xml"); // Assert Assert.Empty(groups); }
public void Read_Should_ReturnGroups_When_ProvidedProperXml() { // Arrange File.Copy("TestConfigurations\\ValidConfig1.xml", "conf\\valid.xml"); var reader = new ConfigurationFileReader(); // Act var groups = reader.Read("conf\\valid.xml"); // Assert Assert.NotEmpty(groups); }
public void Read_Should_ReturnNoGroups_When_ProvidedXmlWithoutHealthChecks() { // Arrange File.Copy("TestConfigurations\\EmptyHealthChecks.xml", "conf\\invalid.xml"); var reader = new ConfigurationFileReader(); // Act var groups = reader.Read("conf\\invalid.xml"); // Assert Assert.Empty(groups); }
public void Read_Should_ReturnNoCalendars_When_ProvidedUnknownElement() { // Arrange File.Copy("TestConfigurations\\CalendarInvalidExclusion.xml", "conf\\calendar.xml"); var reader = new ConfigurationFileReader(); // Act var groups = reader.Read("conf\\calendar.xml"); var check = groups.FirstOrDefault().Checks.FirstOrDefault(); // Assert Assert.Equal(0, check.QuietPeriods.Count); }
public void Read_Should_ReturnCronCalendar_When_ProvidedCronElement() { // Arrange File.Copy("TestConfigurations\\CalendarCronExclusion.xml", "conf\\calendar.xml"); var reader = new ConfigurationFileReader(); // Act var groups = reader.Read("conf\\calendar.xml"); var check = groups.FirstOrDefault().Checks.FirstOrDefault(); // Assert _ = Assert.IsAssignableFrom <CronCalendar>(check.QuietPeriods.Calendars.FirstOrDefault()); }
public void Read_Should_ReturnParsedExclusionCorrectly_When_ProvidedMultipleQuietPeriods() { // Arrange File.Copy("TestConfigurations\\CalendarTwoCronExclusion.xml", "conf\\calendar.xml"); var reader = new ConfigurationFileReader(); var today = DateTime.UtcNow; var eventTime = new DateTimeOffset( new DateTime(today.Year, today.Month, 15, 7, 0, 0, DateTimeKind.Local)); // Act var groups = reader.Read("conf\\calendar.xml"); var check = groups.FirstOrDefault().Checks.FirstOrDefault(); // Assert Assert.True(check.QuietPeriods.IsQuietPeriod(eventTime)); }