Ejemplo n.º 1
0
        public void ScopedCallSite_Test()
        {
            int x = 1;
            var callSite = new ScopedCallSite(() => lmps => x++);

            var t = new Thread(() =>
            {
                Assert.Equal(1, callSite.Invoke());
                Assert.Equal(1, callSite.Invoke());
            });
            t.Start();
            t.Join();
            var t2 = new Thread(() =>
            {
                Assert.Equal(2, callSite.Invoke());
                Assert.Equal(2, callSite.Invoke());
            });
            t2.Start();
            t2.Join();

            Assert.Equal(3, x);
            Assert.Equal(ServiceLifetime.Scoped, callSite.Lifetime);
        }