public void AddValue() { TimestampSeries ts = new TimestampSeries(); ts.AddValue(new DateTime(2010, 1, 2), 1); ts.AddValue(new DateTime(2010, 1, 1), 0); ts.AddValue(new DateTime(2010, 1, 3), 2); ts.AddValue(new DateTime(2010, 1, 4), 3); Assert.AreEqual(4, ts.Items.Count); Assert.AreEqual(0, ts.Items[0].Value); Assert.AreEqual(1, ts.Items[1].Value); Assert.AreEqual(2, ts.Items[2].Value); Assert.AreEqual(3, ts.Items[3].Value); ts.AddValue(new DateTime(2010, 1, 1, 12, 0, 0), 0.5); //testing isert Assert.AreEqual(5, ts.Items.Count); Assert.AreEqual(0, ts.Items[0].Value); Assert.AreEqual(0.5, ts.Items[1].Value); Assert.AreEqual(1, ts.Items[2].Value); Assert.AreEqual(2, ts.Items[3].Value); Assert.AreEqual(3, ts.Items[4].Value); ts.AddValue(new DateTime(2010, 1, 3, 0, 0, 0), 77); // testing overwrite Assert.AreEqual(5, ts.Items.Count); Assert.AreEqual(0, ts.Items[0].Value); Assert.AreEqual(0.5, ts.Items[1].Value); Assert.AreEqual(1, ts.Items[2].Value); Assert.AreEqual(77, ts.Items[3].Value); Assert.AreEqual(3, ts.Items[4].Value); }
public void PropertyChangedEvent() { TimestampSeries timeSeries = new TimestampSeries(); timeSeries.Unit = new HydroNumerics.Core.Unit("liter/sec", 0.001, 0.0, "liters pr. second"); timeSeries.AddValue(new DateTime(2010, 1, 1, 0, 0, 0), 5.0); timeSeries.AddValue(new DateTime(2010, 1, 2, 0, 0, 0), 5.0); timeSeries.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(timeSeries_PropertyChanged); propertyChanged = false; timeSeries.Name = "something else"; Assert.IsTrue(propertyChanged); propertyChanged = false; timeSeries.Items[0].Value = 7.3; Assert.IsTrue(propertyChanged); propertyChanged = false; timeSeries.IsVisible = false; Assert.IsTrue(propertyChanged); Assert.AreEqual("IsVisible", changedProperty); //TODO: implement test like above for the remaining properties }