Ejemplo n.º 1
0
        public void Serializer_Qubscribable_WithPolicy()
        {
            var input = new QuotedSubscribable <int>(Subscribable.Empty <int>(), ((Expression <Func <ISubscribable <int> > >)(() => Subscribable.Empty <int>())).Body);

            var policy = new TestPolicy();

            Assert.AreEqual(0, policy.ConstantHoisterCalls);
            Assert.AreEqual(0, policy.DelegateCacheCalls);
            Assert.AreEqual(0, policy.InMemoryCacheCalls);
            Assert.AreEqual(0, policy.OutlineCompilationCalls);
            Assert.AreEqual(0, policy.ReflectionProviderCalls);
            Assert.AreEqual(0, policy.ExpressionFactoryCalls);

            var quotedResult = Roundtrip(input, new Serializer(policy, SerializerVersioning.v1));

            Assert.AreEqual(1, policy.ConstantHoisterCalls);
            Assert.AreEqual(1, policy.DelegateCacheCalls);
            Assert.AreEqual(1, policy.InMemoryCacheCalls);
            Assert.AreEqual(1, policy.OutlineCompilationCalls);
            Assert.AreEqual(1, policy.ReflectionProviderCalls);
            Assert.AreEqual(1, policy.ExpressionFactoryCalls);

            Assert.IsNotNull(quotedResult);
            Assert.AreEqual(input.Value.GetType(), quotedResult.Value.GetType());
        }
Ejemplo n.º 2
0
        public void Throttle_ArgumentChecking()
        {
            var someObservable = Subscribable.Empty <int>();

            ReactiveAssert.Throws <ArgumentNullException>(() => Subscribable.Throttle(default(ISubscribable <int>), TimeSpan.Zero));
            ReactiveAssert.Throws <ArgumentOutOfRangeException>(() => Subscribable.Throttle(someObservable, TimeSpan.FromSeconds(-1)));
        }
Ejemplo n.º 3
0
        public void Serializer_QubscribableRoundtrips()
        {
            var input = new QuotedSubscribable <int>(Subscribable.Empty <int>(), ((Expression <Func <ISubscribable <int> > >)(() => Subscribable.Empty <int>())).Body);

            var quotedResult = Roundtrip(input, new Serializer(DefaultExpressionPolicy.Instance, SerializerVersioning.v1));

            Assert.IsNotNull(quotedResult);
            Assert.AreEqual(input.Value.GetType(), quotedResult.Value.GetType());
        }
Ejemplo n.º 4
0
        public void Finally_OnlyCalledOnce_Empty()
        {
            var invokeCount    = 0;
            var someObservable = Subscribable.Empty <int>().Finally(() => { invokeCount++; });
            var d = someObservable.Subscribe();

            d.Dispose();
            d.Dispose();

            Assert.AreEqual(1, invokeCount);
        }
Ejemplo n.º 5
0
#pragma warning disable IDE0060 // Remove unused parameter (used to make declarative tests compile in glitching as well)
        public static ISubscribable <T> Empty <T>(this TestScheduler scheduler)
        {
            return(Subscribable.Empty <T>());
        }