public void adding_an_item_updates_the_current() { var model = new DoubleCollectionModel(); var observer = model.CreateObserver(); model.Add(1d); Assert.Equal(1d, model.Current); model.Add(2d); Assert.Equal(2d, model.Current); Assert.Equal(2, observer.GetChangeCount(x => x.Current)); }
public void adding_an_item_updates_the_current_delta_type_if_it_has_changed() { var model = new DoubleCollectionModel(); var observer = model.CreateObserver(); model.Add(1d); Assert.Equal(DeltaType.None, model.CurrentDeltaType); model.Add(2d); Assert.Equal(DeltaType.Increase, model.CurrentDeltaType); model.Add(1d); Assert.Equal(DeltaType.Decrease, model.CurrentDeltaType); model.Add(1d); Assert.Equal(DeltaType.None, model.CurrentDeltaType); Assert.Equal(3, observer.GetChangeCount(x => x.CurrentDeltaType)); }
public void adding_an_item_adds_it_to_the_items() { var model = new DoubleCollectionModel(); model.Add(1d); Assert.Equal(1, model.Items.Count); Assert.Equal(1d, model.Items[0]); }
public void adding_an_item_updates_the_maximum_if_it_has_changed() { var model = new DoubleCollectionModel(); var observer = model.CreateObserver(); for(double item = -5d; item < 5d; ++item) { model.Add(item); Assert.Equal(item, model.Maximum); model.Add(item - 1); Assert.Equal(item, model.Maximum); } Assert.Equal(10, observer.GetChangeCount(x => x.Maximum)); }
public void can_reset() { var model = new DoubleCollectionModel(); model.Add(1d); model.Add(2d); model.Reset(); assert_has_default_property_values(model); }
public void add_throws_if_item_a_not_a_number() { var model = new DoubleCollectionModel(); Assert.Throws<ArgumentOutOfRangeException>(() => model.Add(Double.NaN)); }
public void adding_an_item_updates_the_standard_deviation() { var model = new DoubleCollectionModel(); var observer = model.CreateObserver(); for(double item = 0d; item < 10d; ++item) { model.Add(item); } Assert.Equal(2.8722813232690143, model.StandardDeviation); Assert.Equal(10, observer.GetChangeCount(x => x.StandardDeviation)); }
public void adding_an_item_updates_the_range() { var model = new DoubleCollectionModel(); var observer = model.CreateObserver(); model.Add(1d); Assert.Equal(0d, model.Range); model.Add(10d); Assert.Equal(9d, model.Range); Assert.Equal(2, observer.GetChangeCount(x => x.Range)); model = new DoubleCollectionModel(); observer = model.CreateObserver(); model.Add(-20); Assert.Equal(0d, model.Range); model.Add(-10); Assert.Equal(10d, model.Range); model.Add(0d); Assert.Equal(20d, model.Range); model.Add(10d); Assert.Equal(30d, model.Range); Assert.Equal(4, observer.GetChangeCount(x => x.Range)); }