public void adding_an_item_updates_the_current() { var model = new PostedTimeCollectionModel(); var observer = model.CreateObserver(); var current = PT(35d, PostedTimeType.Normal, 5); model.Add(current); Assert.Equal(current, model.Current); current = PT(65d, PostedTimeType.Normal, 5); model.Add(current); Assert.Equal(current, model.Current); Assert.Equal(2, observer.GetChangeCount(x => x.Current)); }
public void adding_an_item_updates_the_maximum_if_it_has_changed() { PostedTime item; var model = new PostedTimeCollectionModel(); var observer = model.CreateObserver(); for(double seconds = 1d; seconds < 6d; ++seconds) { item = PT(seconds, PostedTimeType.Normal, 5); model.Add(item); Assert.Equal(item, model.Maximum); model.Add(PT(seconds - 1, PostedTimeType.Normal, 5)); Assert.Equal(item, model.Maximum); } Assert.Equal(5, observer.GetChangeCount(x => x.Maximum)); }
public void adding_an_item_adds_it_to_the_items() { var item = PT(32, PostedTimeType.Normal, 5); var model = new PostedTimeCollectionModel(); model.Add(item); Assert.Equal(1, model.Items.Count); Assert.Equal(item, model.Items[0]); }
public void adding_an_item_updates_the_mean() { var model = new PostedTimeCollectionModel(); var observer = model.CreateObserver(); model.Add(PT(1d, PostedTimeType.Normal, 1)); Assert.Equal(TS(1d), model.Mean); model.Add(PT(1d, PostedTimeType.Normal, 1)); Assert.Equal(TS(1d), model.Mean); model.Add(PT(4d, PostedTimeType.Normal, 1)); Assert.Equal(TS(2d), model.Mean); Assert.Equal(2, observer.GetChangeCount(x => x.Mean)); }
public void replacing_an_item_updates_the_session_best_count() { var model = new PostedTimeCollectionModel(); var observer = model.CreateObserver(); model.Add(PT(15, PostedTimeType.SessionBest, 1)); Assert.Equal(1, model.SessionBestCount); model.ReplaceCurrent(PT(15, PostedTimeType.SessionBest, 1)); Assert.Equal(1, model.SessionBestCount); model.ReplaceCurrent(PT(15, PostedTimeType.Normal, 1)); Assert.Equal(0, model.SessionBestCount); model.ReplaceCurrent(PT(15, PostedTimeType.SessionBest, 1)); Assert.Equal(1, model.SessionBestCount); model.ReplaceCurrent(PT(15, PostedTimeType.PersonalBest, 1)); Assert.Equal(0, model.SessionBestCount); Assert.Equal(4, observer.GetChangeCount(x => x.SessionBestCount)); }
public void replacing_an_item_updates_the_range() { var model = new PostedTimeCollectionModel(); var observer = model.CreateObserver(); model.Add(PT(10, PostedTimeType.Normal, 1)); Assert.Equal(TS(0), model.Range); model.ReplaceCurrent(PT(10, PostedTimeType.Normal, 1)); Assert.Equal(TS(0), model.Range); model.Add(PT(20, PostedTimeType.Normal, 1)); model.ReplaceCurrent(PT(10, PostedTimeType.Normal, 1)); Assert.Equal(TS(10), model.Range); Assert.Equal(2, observer.GetChangeCount(x => x.Range)); }
public void replacing_an_item_updates_the_minimum_if_it_has_changed() { var model = new PostedTimeCollectionModel(); var observer = model.CreateObserver(); var replacement = PT(20, PostedTimeType.Normal, 1); model.Add(PT(30, PostedTimeType.Normal, 1)); observer.ClearChanges(); model.ReplaceCurrent(replacement); Assert.Equal(replacement, model.Minimum); Assert.True(observer.HasChanged(x => x.Minimum)); model.Add(PT(10, PostedTimeType.Normal, 1)); observer.ClearChanges(); replacement = PT(5, PostedTimeType.Normal, 1); model.ReplaceCurrent(replacement); Assert.Equal(replacement, model.Minimum); Assert.True(observer.HasChanged(x => x.Minimum)); }
public void replacing_an_item_updates_the_items() { var model = new PostedTimeCollectionModel(); var replacement = PT(50, PostedTimeType.Normal, 1); model.Add(PT(1, PostedTimeType.Normal, 1)); model.ReplaceCurrent(replacement); Assert.Equal(replacement, model.Items[0]); }
public void replacing_an_item_updates_the_mean() { var model = new PostedTimeCollectionModel(); var observer = model.CreateObserver(); model.Add(PT(1, PostedTimeType.Normal, 1)); model.ReplaceCurrent(PT(10, PostedTimeType.Normal, 1)); Assert.Equal(TS(10), model.Mean); Assert.True(observer.HasChanged(x => x.Mean)); }
public void replacing_an_item_does_not_update_the_count() { var model = new PostedTimeCollectionModel(); var observer = model.CreateObserver(); model.Add(PT(1, PostedTimeType.Normal, 1)); observer.ClearChanges(); model.ReplaceCurrent(PT(10, PostedTimeType.Normal, 1)); Assert.Equal(1, model.Count); Assert.False(observer.HasChanged(x => x.Count)); }
public void can_reset() { var model = new PostedTimeCollectionModel(); model.Add(PT(65d, PostedTimeType.PersonalBest, 5)); model.Reset(); assert_has_default_property_values(model); }
public void bug() { var model = new PostedTimeCollectionModel(); var time = PT(23.3, PostedTimeType.SessionBest, 0); model.Add(time); model.ReplaceCurrent(PT(23.3, PostedTimeType.PersonalBest, 0)); Assert.NotEqual(time, model.Minimum); }
public void add_throws_if_item_is_null() { var model = new PostedTimeCollectionModel(); Assert.Throws<ArgumentNullException>(() => model.Add(null)); }
public void adding_an_item_updates_the_session_best_count() { var model = new PostedTimeCollectionModel(); var observer = model.CreateObserver(); model.Add(PT(15, PostedTimeType.SessionBest, 1)); Assert.Equal(1, model.SessionBestCount); Assert.True(observer.HasChanged(x => x.SessionBestCount)); }