public void RemovedWhenNoLongerInBoth() { _source1.Add(1); _source2.Add(1); _source1.Remove(1); Assert.AreEqual(1, _results.Data.Count); }
public void Removes() { _source.AddRange(Enumerable.Range(1, 5)); _source.Remove(1); _source.Remove(4); CollectionAssert.AreEquivalent(new[] { 5, 3, 2 }, _results.Data.Items); }
public void RemovedWhenNoLongerInBoth() { _source1.Add(1); _source2.Add(1); _source1.Remove(1); _results.Data.Count.Should().Be(1); }
public void Removes() { _source.AddRange(Enumerable.Range(1, 5)); _source.Remove(1); _source.Remove(4); _results.Data.Items.ShouldAllBeEquivalentTo(new[] { 5, 3, 2 }); }
public void RemovingAnItemRemovesTheDistinct() { var person = new Person("Person1", 20); _source.Add(person); _source.Remove(person); _results.Messages.Count.Should().Be(2, "Should be 1 update message"); _results.Data.Count.Should().Be(0, "Should be 1 items in the cache"); _results.Messages.First().Adds.Should().Be(1, "First message should be an add"); _results.Messages.Skip(1).First().Removes.Should().Be(1, "Second messsage should be a remove"); }
public void RemoveFiltered() { var person = new Person("P1", 1); _source.Add(person); _results.Data.Count.Should().Be(0, "Should be 0 people in the cache"); _filter.OnNext(p => p.Age >= 1); _results.Data.Count.Should().Be(1, "Should be 1 people in the cache"); _source.Remove(person); _results.Data.Count.Should().Be(0, "Should be 0 people in the cache"); }
public void Remove() { const string key = "Adult1"; var person = new Person(key, 50); _source.Add(person); _source.Remove(person); _results.Messages.Count.Should().Be(2, "Should be 2 updates"); _results.Messages.Count.Should().Be(2, "Should be 2 updates"); _results.Messages[0].Adds.Should().Be(1, "Should be 80 addes"); _results.Messages[1].Removes.Should().Be(1, "Should be 80 removes"); _results.Data.Count.Should().Be(0, "Should be nothing cached"); }
public void AddingRemovedItem() { var person = new Person("A", 20); _source.Add(person); _source.Remove(person); _source.Add(person); _results.Messages.Count.Should().Be(3, "Should be 2 updates"); _results.Data.Count.Should().Be(1, "Should be 1 item in the cache"); _results.Data.Items.Should().BeEquivalentTo(new[] { 20 }); _results.Messages.ElementAt(0).Adds.Should().Be(1, "First message should be an add"); _results.Messages.ElementAt(1).Removes.Should().Be(1, "Second message should be a remove"); _results.Messages.ElementAt(2).Adds.Should().Be(1, "Third message should be an add"); }
public void AddedWhenNoLongerInSecond() { _source1.Add(1); _source2.Add(1); _source2.Remove(1); Assert.AreEqual(1, _results.Data.Count); }
void IDependencyObjectReceiver.Receive(DependencyObject value) { if (!(value is DataGrid grid)) { return; } _grid = grid; IDisposable rowsAdded = Observable.FromEventPattern <DataGridRowEventArgs> ( ev => _grid.LoadingRow += ev, ev => _grid.LoadingRow -= ev ).Select(e => e.EventArgs.Row) .Subscribe(datagridrow => _visibleRowsSource.Add((T)datagridrow.Item));; IDisposable rowsUnloaded = Observable.FromEventPattern <DataGridRowEventArgs> ( ev => _grid.UnloadingRow += ev, ev => _grid.UnloadingRow -= ev ).Select(e => e.EventArgs.Row) .Subscribe(datagridrow => _visibleRowsSource.Remove((T)datagridrow.Item)); _cleanUp.Disposable = new CompositeDisposable(rowsAdded, rowsUnloaded, _visibleRows, _visibleRowsSource); }
public void AddedWhenNoLongerInSecond() { Source1.Add(1); Source2.Add(1); Source2.Remove(1); _results.Data.Count.Should().Be(1); }
public void RemovedWhenNoLongerInEither() { _source.Add(_source1.Connect()); _source.Add(_source2.Connect()); _source1.Add(1); _source1.Remove(1); Assert.AreEqual(0, _results.Data.Count); }
public void Remove() { _source.Add(new Person("Person1", 20)); _source.Remove(new Person("Person1", 20)); Assert.AreEqual(2, _results.Messages.Count); Assert.AreEqual(0, _results.Data.Count); }
public void RemovedWhenNoLongerInEither() { _source.Add(_source1.Connect()); _source.Add(_source2.Connect()); _source1.Add(1); _source1.Remove(1); _results.Data.Count.Should().Be(0); }
public void CanRemoveFromGroup() { var person = new Person("A", 10); _source.Add(person); _source.Remove(person); _results.Data.Count.Should().Be(0); }
private async Task MessageQueueOnWork(OperationComponent arg) { _eventSystem.Publish(new OperationStartedEvent(arg.OpsId)); await arg.Task(arg.Data); _operations.Remove(arg); _eventSystem.Publish(new OperationFinishtEvent(arg.OpsId)); }
public void AddedWhenNoLongerInSecond() { _source.Add(_source1.Connect()); _source.Add(_source2.Connect()); _source1.Add(1); _source2.Add(1); _source2.Remove(1); _results.Data.Count.Should().Be(1); }
public void CanRemoveFromGroup() { var person = new Person("A", 10); _source.Add(person); _source.Remove(person); Assert.AreEqual(0, _results.Data.Count); }
public void Remove() { var person = new Person("Adult1", 50); _source.Add(person); _source.Remove(person); Assert.AreEqual(2, _results.Messages.Count, "Should be 1 updates"); Assert.AreEqual(0, _results.Data.Count, "Should be no groups"); }
public void Remove() { var person = new Person("Adult1", 50); _source.Add(person); _source.Remove(person); _results.Messages.Count.Should().Be(2, "Should be 1 updates"); _results.Data.Count.Should().Be(0, "Should be no groups"); }
public void Remove() { var person = new Person("Person1", 20); _source.Add(person); _source.Remove(person); _results.Messages.Count.Should().Be(2); _results.Data.Count.Should().Be(0); }
public void RemovingAnItemRemovesTheDistinct() { _source.Add(new Person("Person1", 20)); _source.Remove(new Person("Person1", 20)); Assert.AreEqual(2, _results.Messages.Count, "Should be 1 update message"); Assert.AreEqual(0, _results.Data.Count, "Should be 1 items in the cache"); Assert.AreEqual(1, _results.Messages.First().Adds, "First message should be an add"); Assert.AreEqual(1, _results.Messages.Skip(1).First().Removes, "Second messsage should be a remove"); }
public void RemoveParent() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); _source.Add(mother); _source.Remove(mother); _results.Data.Count.Should().Be(0); }
public void CanHandleAddsAndUpdates() { bool invoked = false; var subscription = _source.Connect().QueryWhenChanged(q => q.Count).Subscribe(query => invoked = true); var person = new Person("A", 1); _source.Add(person); _source.Remove(person); invoked.Should().BeTrue(); subscription.Dispose(); }
public IDisposable AddStatusBarItem(object item) { Guard.ArgumentNotNull(item, nameof(item)); Log.Debug($"Adding item {item} to StatusBar, items: {StatusBarItems.DumpToTextRaw()}"); statusBarItemsSource.Add(item); return(Disposable.Create( () => { Log.Debug($"Removing item {item} from StatusBar, items: {StatusBarItems.DumpToTextRaw()}"); statusBarItemsSource.Remove(item); })); }
public void Remove() { const string key = "Adult1"; var person = new Person(key, 50); _source.Add(person); _source.Remove(person); Assert.AreEqual(2, _results.Messages.Count, "Should be 2 updates"); Assert.AreEqual(2, _results.Messages.Count, "Should be 2 updates"); Assert.AreEqual(1, _results.Messages[0].Adds, "Should be 80 addes"); Assert.AreEqual(1, _results.Messages[1].Removes, "Should be 80 removes"); Assert.AreEqual(0, _results.Data.Count, "Should be nothing cached"); }
public void ChildrenAreRemovedWhenParentIsRemoved() { var frientofchild1 = new PersonWithRelations("Friend1", 10); var child1 = new PersonWithRelations("Child1", 10, new[] { frientofchild1 }); var child2 = new PersonWithRelations("Child2", 8); var child3 = new PersonWithRelations("Child3", 8); var mother = new PersonWithRelations("Mother", 35, new[] { child1, child2, child3 }); // var father = new PersonWithRelations("Father", 35, new[] {child1, child2, child3, mother}); _source.Add(mother); _source.Remove(mother); Assert.AreEqual(0, _results.Data.Count, "Should be 4 in the cache"); }
public void RemovedItemWillNotCauseInvocation() { bool invoked = false; var stream = _source.Connect() .MergeMany(o => o.Observable) .Subscribe(o => { invoked = true; }); var item = new ObjectWithObservable(1); _source.Add(item); _source.Remove(item); Assert.IsFalse(invoked, "Error. The operator should not have been invoked"); item.InvokeObservable(true); Assert.IsFalse(invoked, "The observable should not have notified as it is no longer in the stream"); stream.Dispose(); }
public void RemovedItemWillNotCauseInvocation() { bool invoked = false; var stream = _source.Connect() .MergeMany(o => o.Observable) .Subscribe(o => { invoked = true; }); var item = new ObjectWithObservable(1); _source.Add(item); _source.Remove(item); invoked.Should().BeFalse(); item.InvokeObservable(true); invoked.Should().BeFalse(); stream.Dispose(); }
public void RemoveRandomSorts() { //seems an odd test but believe me it catches exceptions when sorting on primitives var items = Enumerable.Range(1, 100).OrderBy(_ => Guid.NewGuid()).ToArray(); _source.AddRange(items); _results.Data.Count.Should().Be(100); var expectedResult = items.OrderBy(p => p, _comparer); var actualResult = _results.Data.Items; actualResult.Should().BeEquivalentTo(expectedResult); for (int i = 0; i < 50; i++) { _source.Remove(i); } }