Exemplo n.º 1
0
        public void CalculatesIntOnceTest()
        {
            var        value = 0;
            Func <int> supp  = () =>
            {
                ++value;
                return(value);
            };

            lazyInt = LazyFactory <int> .CreateSingleThread(supp);

            lazyInt.Get();
            Assert.AreEqual(1, lazyInt.Get());
        }
Exemplo n.º 2
0
        public void CalculatesStrOnceTest()
        {
            var           value = "";
            Func <string> supp  = () =>
            {
                value += "Hoba! ";
                return(value);
            };

            lazyStr = LazyFactory <string> .CreateSingleThread(supp);

            lazyStr.Get();
            lazyStr.Get();
            Assert.AreEqual("Hoba! ", lazyStr.Get());
        }
Exemplo n.º 3
0
 public void NullTest()
 {
     Assert.Throws <ArgumentNullException>(() => lazyStr = LazyFactory <string> .CreateSingleThread(null));
 }
Exemplo n.º 4
0
        public void NormalIntTest()
        {
            lazyInt = LazyFactory <int> .CreateSingleThread(() => 100);

            Assert.AreEqual(100, lazyInt.Get());
        }