예제 #1
0
 public void AddedWhenNoLongerInSecond()
 {
     Source1.Add(1);
     Source2.Add(1);
     Source2.Remove(1);
     _results.Data.Count.Should().Be(1);
 }
예제 #2
0
 public void NothingFromOther()
 {
     _source.Add(_source1.Connect());
     _source.Add(_source2.Connect());
     _source2.Add(1);
     _results.Data.Count.Should().Be(0);
 }
예제 #3
0
 public void ExcludedWhenItemIsInOneSource()
 {
     _source.Add(_source1.Connect());
     _source.Add(_source2.Connect());
     _source1.Add(1);
     Assert.AreEqual(0, _results.Data.Count);
 }
예제 #4
0
        public void IncludedWhenItemIsInOneSource()
        {
            _source1.Add(1);

            Assert.AreEqual(1, _results.Data.Count);
            Assert.AreEqual(1, _results.Data.Items.First());
        }
예제 #5
0
 public void NothingFromOther()
 {
     _source.Add(_source1.Connect());
     _source.Add(_source2.Connect());
     _source2.Add(1);
     Assert.AreEqual(0, _results.Data.Count);
 }
예제 #6
0
 public void ExcludedWhenItemIsInOneSource()
 {
     _source.Add(_source1.Connect());
     _source.Add(_source2.Connect());
     _source1.Add(1);
     _results.Data.Count.Should().Be(0);
 }
예제 #7
0
        public void IncludedWhenItemIsInOneSource()
        {
            _source1.Add(1);

            _results.Data.Count.Should().Be(1);
            _results.Data.Items.First().Should().Be(1);
        }
예제 #8
0
        public void AddedItemWillbeSubscribed()
        {
            _source.Add(new SubscribeableObject(1));

            _results.Messages.Count.Should().Be(1, "Should be 1 updates");
            _results.Data.Count.Should().Be(1, "Should be 1 item in the cache");
            _results.Data.Items.First().IsSubscribed.Should().Be(true, "Should be subscribed");
        }
예제 #9
0
 public void NotIncludedWhenItemIsInTwoSources()
 {
     _source.Add(_source1.Connect());
     _source.Add(_source2.Connect());
     _source1.Add(1);
     _source2.Add(1);
     _results.Data.Count.Should().Be(0);
 }
예제 #10
0
        public void FiresAddWhenaNewItemIsAdded()
        {
            _source.Add(new Person("Person1", 20));

            Assert.AreEqual(1, _results.Messages.Count, "Should be 1 updates");
            Assert.AreEqual(1, _results.Data.Count, "Should be 1 item in the cache");
            Assert.AreEqual(20, _results.Data.Items.First(), "Should 20");
        }
예제 #11
0
        public void FiresAddWhenaNewItemIsAdded()
        {
            _source.Add(new Person("Person1", 20));

            _results.Messages.Count.Should().Be(1, "Should be 1 updates");
            _results.Data.Count.Should().Be(1, "Should be 1 item in the cache");
            _results.Data.Items.First().Should().Be(20, "Should 20");
        }
예제 #12
0
        public void AddedItemWillbeSubscribed()
        {
            _source.Add(new SubscribeableObject(1));

            Assert.AreEqual(1, _results.Messages.Count, "Should be 1 updates");
            Assert.AreEqual(1, _results.Data.Count, "Should be 1 item in the cache");
            Assert.AreEqual(true, _results.Data.Items.First().IsSubscribed, "Should be subscribed");
        }
예제 #13
0
 public void IncludedWhenItemIsInTwoSources()
 {
     _source.Add(_source1.Connect());
     _source.Add(_source2.Connect());
     _source1.Add(1);
     _source2.Add(1);
     Assert.AreEqual(1, _results.Data.Count);
 }
예제 #14
0
 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);
 }
예제 #15
0
        public void Add()
        {
            var person = new Person("Adult1", 50);

            _source.Add(person);

            _results.Messages.Count.Should().Be(1, "Should be 1 updates");
            _results.Data.Count.Should().Be(1, "Should be 1 item in the cache");
            _results.Data.Items.First().Should().Be(_transformFactory(person), "Should be same person");
        }
예제 #16
0
        public IEventsDocument CreateEventsDocument(IEnumerable <IInstrumentedCall> calls)
        {
            var callsList = calls.ToArray();
            var doc       = new EventsDocument(this);

            doc.AddRange(callsList);
            doc.DocumentName = callsList.Length == 1 ? $"{callsList[0].CalledMethod} - events" : $"{callsList.Length} calls - events";
            mDocuments.Add(doc);
            return(doc);
        }
예제 #17
0
        public void AddInSucession()
        {
            _source.Add(1);
            _source.Add(2);
            _source.Add(3);
            _source.Add(4);
            _source.Add(5);

            CollectionAssert.AreEquivalent(new [] { 5, 4, 3, 2, 1 }, _results.Data.Items);
        }
예제 #18
0
        public void ClearSource()
        {
            _source1.Add(0);
            _source2.Add(1);
            _source.Add(_source1.Connect());
            _source.Add(_source2.Connect());
            _source.Clear();

            _results.Data.Count.Should().Be(0);
        }
예제 #19
0
        public void AddInSucession()
        {
            _source.Add(1);
            _source.Add(2);
            _source.Add(3);
            _source.Add(4);
            _source.Add(5);

            _results.Data.Items.ShouldAllBeEquivalentTo(new[] { 5, 4, 3, 2, 1 });
        }
예제 #20
0
        public void CanGroupOnAdds()
        {
            _source.Add(new Person("A", 10));

            _results.Data.Count.Should().Be(1);

            var firstGroup = _results.Data.Items.First();

            firstGroup.Count.Should().Be(1);
            firstGroup.Key.Should().Be(10);
        }
예제 #21
0
        public void CanGroupOnAdds()
        {
            _source.Add(new Person("A", 10));

            Assert.AreEqual(1, _results.Data.Count);

            var firstGroup = _results.Data.Items.First();

            Assert.AreEqual(1, firstGroup.List.Count);
            Assert.AreEqual(10, firstGroup.GroupKey);
        }
예제 #22
0
        public void AddLessThanLimit()
        {
            var person = _generator.Take(1).First();

            _source.Add(person);

            _scheduler.AdvanceBy(TimeSpan.FromMilliseconds(150).Ticks);

            Assert.AreEqual(1, _results.Messages.Count, "Should be 1 updates");
            Assert.AreEqual(1, _results.Data.Count, "Should be 1 item in the cache");
            Assert.AreEqual(person, _results.Data.Items.First(), "Should be same person");
        }
예제 #23
0
        public void ChangeInvokedOnSubscriptionIfItHasData()
        {
            bool invoked = false;

            _source.Add(new Person("A", 1));
            var subscription = _source.Connect()
                               .QueryWhenChanged()
                               .Subscribe(x => invoked = true);

            invoked.Should().BeTrue();
            subscription.Dispose();
        }
예제 #24
0
        public void ChangeInvokedOnSubscriptionIfItHasData()
        {
            bool invoked = false;

            _source.Add(new Person("A", 1));
            var subscription = _source.Connect()
                               .QueryWhenChanged()
                               .Subscribe(x => invoked = true);

            Assert.IsTrue(invoked, "Should have received on next");
            subscription.Dispose();
        }
예제 #25
0
        public void NoResultsWillBeReceivedIfPaused()
        {
            _pausingSubject.OnNext(true);
            //advance otherwise nothing happens
            _scheduler.AdvanceBy(TimeSpan.FromMilliseconds(10).Ticks);

            _source.Add(new Person("A", 1));

            //go forward an arbitary amount of time
            _scheduler.AdvanceBy(TimeSpan.FromMinutes(1).Ticks);
            _results.Messages.Count.Should().Be(0, "There should be no messages");
        }
예제 #26
0
        public void ItemIsReplaced()
        {
            _source1.Add(0);
            _source2.Add(1);
            _source.Add(_source1.Connect());
            _source.Add(_source2.Connect());
            _source1.ReplaceAt(0, 9);

            _results.Data.Count.Should().Be(2);
            _results.Messages.Count.Should().Be(3);
            _results.Data.Items.Should().BeEquivalentTo(9, 1);
        }
예제 #27
0
        public void Add()
        {
            var person = new Person("Adult1", 50);

            _source.Add(person);

            Assert.AreEqual(1, _results.Messages.Count, "Should be 1 updates");
            Assert.AreEqual(1, _results.Data.Count, "Should be 1 item in the cache");

            var firstGroup = _results.Data.Items.First().List.Items.ToArray();

            Assert.AreEqual(person, firstGroup[0], "Should be same person");
        }
예제 #28
0
        public async Task Add()
        {
            var person = new Person("Adult1", 50);

            _source.Add(person);

            Assert.AreEqual(1, _results.Messages.Count, "Should be 1 updates");
            Assert.AreEqual(1, _results.Data.Count, "Should be 1 item in the cache");

            var transformed = await _transformFactory(person);

            Assert.AreEqual(transformed, _results.Data.Items.First(), "Should be same person");
        }
예제 #29
0
        public void WillApplyTimeout()
        {
            _pausingSubject.OnNext(true);

            //should timeout
            _scheduler.AdvanceBy(TimeSpan.FromSeconds(61).Ticks);

            _source.Add(new Person("A", 1));

            //go forward an arbitary amount of time
            // _scheduler.AdvanceBy(TimeSpan.FromMinutes(1).Ticks);
            _results.Messages.Count.Should().Be(1, "There should be no messages");
        }
예제 #30
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();
        }