Ejemplo n.º 1
0
        public void Activator_And_Should_Follow_Single_Input()
        {
            var inputs = new[] { new TestSubject <bool>(false) };
            var target = new StyleActivator(inputs, ActivatorMode.And);
            var result = new TestObserver <bool>();

            target.Subscribe(result);
            Assert.False(result.GetValue());
            inputs[0].OnNext(true);
            Assert.True(result.GetValue());
            inputs[0].OnNext(false);
            Assert.False(result.GetValue());
            inputs[0].OnNext(true);
            Assert.True(result.GetValue());

            Assert.Equal(1, inputs[0].SubscriberCount);
        }
Ejemplo n.º 2
0
        public void Activator_Or_Should_Not_Unsubscribe_All_When_Input_Completes_On_False()
        {
            var inputs = new[]
            {
                new TestSubject <bool>(false),
                new TestSubject <bool>(false),
                new TestSubject <bool>(true),
            };
            var target = new StyleActivator(inputs, ActivatorMode.Or);
            var result = new TestObserver <bool>();

            target.Subscribe(result);
            Assert.True(result.GetValue());
            inputs[2].OnNext(false);
            Assert.False(result.GetValue());
            inputs[2].OnCompleted();

            Assert.Equal(1, inputs[0].SubscriberCount);
            Assert.Equal(1, inputs[1].SubscriberCount);
            Assert.Equal(1, inputs[2].SubscriberCount);
        }
Ejemplo n.º 3
0
        public void Activator_Or_Should_OR_Multiple_Inputs()
        {
            var inputs = new[]
            {
                new TestSubject <bool>(false),
                new TestSubject <bool>(false),
                new TestSubject <bool>(true),
            };
            var target = StyleActivator.Or(inputs);
            var result = new TestObserver <bool>();

            target.Subscribe(result);
            Assert.True(result.GetValue());
            inputs[2].OnNext(false);
            Assert.False(result.GetValue());
            inputs[0].OnNext(true);
            Assert.True(result.GetValue());

            Assert.Equal(1, inputs[0].SubscriberCount);
            Assert.Equal(1, inputs[1].SubscriberCount);
            Assert.Equal(1, inputs[2].SubscriberCount);
        }
Ejemplo n.º 4
0
        public void Activator_And_Should_AND_Multiple_Inputs()
        {
            var inputs = new[]
            {
                new TestSubject <bool>(false),
                new TestSubject <bool>(false),
                new TestSubject <bool>(true),
            };
            var target = new StyleActivator(inputs, ActivatorMode.And);
            var result = new TestObserver <bool>();

            target.Subscribe(result);
            Assert.IsFalse(result.GetValue());
            inputs[0].OnNext(true);
            inputs[1].OnNext(true);
            Assert.IsTrue(result.GetValue());
            inputs[0].OnNext(false);
            Assert.IsFalse(result.GetValue());

            Assert.AreEqual(1, inputs[0].SubscriberCount);
            Assert.AreEqual(1, inputs[1].SubscriberCount);
            Assert.AreEqual(1, inputs[2].SubscriberCount);
        }