コード例 #1
0
        public void CollectionChangedHandlerInvokedForTake()
        {
            IEnumerable <int> loadedInts = new[] { 42 };
            var loader = new AsyncLoader <int>(
                Seq.ListBased,
                loadDataAsync: tok => Task.FromResult(loadedInts),
                eventContext: new RunInlineSynchronizationContext());

            loader.LoadAsync();  // load initial items

            var listener = Substitute.For <CollectionChangedHandler <int> >();

            loader.CollectionChanged += listener;


            loader.Take();  // --- Perform ---


            listener.Received().Invoke(loader, Fluent.Match <IntChangesAlias>(changes =>
                                                                              changes.Should().ContainSingle().Which.ShouldBeEquivalentTo(new ItemChange <int>(ChangeType.Removed, 42))));
        }