Exemplo n.º 1
0
 public void AssertGetBackAfterUsing1()
 {
     using var _ = MaxExpansionTermCount.Set(10);
     using (var __ = MaxExpansionTermCount.Set(25))
         Assert.Equal(25, MaxExpansionTermCount.Value);
     Assert.Equal(10, MaxExpansionTermCount.Value);
 }
Exemplo n.º 2
0
        public void AssertCorrectAssigning()
        {
            using var _ = MaxExpansionTermCount.Set(4);
            var actual = MaxExpansionTermCount.Value;

            Assert.Equal(4, actual);
            using var __ = MaxExpansionTermCount.Set(5);
            var actual2 = MaxExpansionTermCount.Value;

            Assert.Equal(5, actual2);
            using var ___ = MaxExpansionTermCount.Set(30902);
            var actual3 = MaxExpansionTermCount.Value;

            Assert.Equal(30902, actual3);
        }
Exemplo n.º 3
0
        public void AssertGetBackDespiteDispose()
        {
            using var _ = MaxExpansionTermCount.Set(67);
            Assert.Equal(67, MaxExpansionTermCount.Value);
            {
                using var d1 = MaxExpansionTermCount.Set(34);
                using var d2 = MaxExpansionTermCount.Set(87);

                // normally, it is called after d2.Dispose(), but what if we call it here...
                d1.Dispose();

                // d1 was disposed, but d2 was not.
                // Since it was the last one,
                // the setting will remain equal to d2
                Assert.Equal(87, MaxExpansionTermCount.Value);
            }
            Assert.Equal(67, MaxExpansionTermCount.Value);
        }