public void GetNextAlarm() { var alarmsConfig = @" 10:45 file1 12:00 file2 22:00 file3 22:30 file4 "; var lines = alarmsConfig.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); var parser = new AlarmParser("invalid_config_file"); var result = parser.GetNextAlarm(TimeSpan.FromHours(11.00), parser.Parse(lines)); result.ShouldBeEquivalentTo(new AlarmConfig { Time = TimeSpan.FromHours(12.00), SoundPath = "file2", }); }
public void ParseAlarm() { var alarmsConfig = @" 10:45 file1 11:30 url1 12:00 file2 22:00 url2 22:30 file3 23:00 url3 "; var lines = alarmsConfig.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); var parser = new AlarmParser("invalid_config_file"); var result = parser.Parse(lines); result.Should().Equal( new AlarmConfig[] { new AlarmConfig { Time = TimeSpan.FromHours(10.75), SoundPath = "file1" }, new AlarmConfig { Time = TimeSpan.FromHours(11.5), SoundPath = "url1" }, new AlarmConfig { Time = TimeSpan.FromHours(12), SoundPath = "file2" }, new AlarmConfig { Time = TimeSpan.FromHours(22), SoundPath = "url2" }, new AlarmConfig { Time = TimeSpan.FromHours(22.5), SoundPath = "file3" }, new AlarmConfig { Time = TimeSpan.FromHours(23), SoundPath = "url3" } } ); }