コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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));
        }