public ServiceInformation(Sun sun, Weather weather) { sun.Resolve(); Sunrise = sun.Sunrise; Sunset = sun.Sunset; weather.Resolve(); Temperature = weather.Temperature; }
public override void Resolve() { base.Resolve(); Sun sun = new Sun(); JToken root = JObject.Parse(LastResponse); JToken results = root["results"]; Sun deserializedSun = JsonConvert.DeserializeObject<Sun>(results.ToString()); Sunrise = deserializedSun.Sunrise; Sunset = deserializedSun.Sunset; }
public void SunriseSunSetAPITest() { Sun sun = new Sun(); sun.Resolve(); Assert.IsFalse(sun.ErrorDetected, string.Format(errorDownloadResponse, sun.Name)); Assert.IsTrue(sun.LastUpdatedSuccessful.HasValue); Assert.AreNotEqual<DateTime>(DateTime.MinValue, sun.LastUpdatedSuccessful.Value); Assert.IsNotNull(sun.LastResponse, string.Format(errorResponseNull, sun.Name)); Assert.IsNotNull(sun.Sunrise); Assert.IsNotNull(sun.Sunset); Assert.AreNotEqual<DateTime>(DateTime.MinValue, sun.Sunrise); Assert.AreNotEqual<DateTime>(DateTime.MinValue, sun.Sunset); }
/// <summary> /// /// </summary> private void sunMode(DateTime dateTime, Program program) { if (_sun == null) _sun = new Sun(); _sun.Resolve(); // Power device on if (dateTime.Hour == _sun.Sunset.Hour && dateTime.Minute == _sun.Sunset.Minute) program.PowerDevicesOn(); // Power device off if (dateTime.Hour == program.EndTime.Value.Hour && dateTime.Minute == program.EndTime.Value.Minute) program.PowerDevicesOff(); }