Пример #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();
        }