コード例 #1
0
        public void TestMovingMultipleOccurrences()
        {
            ReactiveList <string> list = new ReactiveArrayList <string> {
                "A", "B", "A", "C"
            };

            list.Move("A", list.Count - 1);
            Assert.IsTrue(list.SequenceEqual(new[] { "B", "A", "C", "A" }));
        }
コード例 #2
0
        public void TestAdding()
        {
            ReactiveList <string> list = new ReactiveArrayList <string>();

            Assert.AreEqual(0, list.Count);
            list.Add("B");
            Assert.AreEqual(1, list.Count);
            list.Insert(0, "A");
            list.Insert(2, "C");
            Assert.IsTrue(list.SequenceEqual(new[] { "A", "B", "C" }));
        }
コード例 #3
0
        public Diagram()
        {
            Messages = new ReactiveArrayList <Message>();
            Parties  = new ReactiveArrayList <Party>();

            Parties.OnDelete.Subscribe(e =>
            {
                var messagesToBeRemoved = Messages
                                          .Where(message => message.Sender == e.Element || message.Receiver == e.Element);
                Messages.RemoveAll(messagesToBeRemoved);
            });
        }
コード例 #4
0
        public void TestRemoving()
        {
            ReactiveList <string> list = new ReactiveArrayList <string> {
                "A", "B", "C"
            };

            Assert.AreEqual(3, list.Count);
            Assert.IsTrue(list.Remove("B"));
            Assert.AreEqual(2, list.Count);
            list.RemoveAt(1);
            list.RemoveAt(0);
            Assert.IsTrue(list.SequenceEqual(new string[0]));
        }
コード例 #5
0
        public void TestMoving()
        {
            ReactiveList <string> list = new ReactiveArrayList <string> {
                "A", "B", "C"
            };

            Assert.AreEqual(3, list.Count);
            list.Move("B", list.Count - 1);
            Assert.AreEqual(3, list.Count);
            Assert.IsTrue(list.SequenceEqual(new[] { "A", "C", "B" }));

            list.Move("A", 0);
            Assert.AreEqual(3, list.Count);
            Assert.IsTrue(list.SequenceEqual(new[] { "A", "C", "B" }));
        }
コード例 #6
0
        public void TestMovingForwardObservables()
        {
            //Setup
            var scheduler = new TestScheduler();
            ReactiveList <string> list = new ReactiveArrayList <string> {
                "A", "B", "C", "D", "E"
            };

            //Define actions
            scheduler.Schedule(TimeSpan.FromTicks(10), () => list.Move("B", 3));
            var actual = scheduler.Start(() => list.OnMoved, created: 0, subscribed: 0, disposed: 100);

            //Assert
            Assert.AreEqual(1, actual.Messages.Count);
            foreach (var actualMessages in actual.Messages)
            {
                Assert.True(Enumerable.SequenceEqual(actualMessages.Value.Value.Changes, new[]