using System; using System.Collections.Generic; using System.Linq; using System.Utility; using NUnit.Framework; namespace Chernobyl { [TestFixture, Description("Tests for LazyExt type")] public class LazyTests { [Test] public void SwitchCreatesOnlyWhenNeeded() { var lazy = new Lazy>(() => Enumerable.Range(1, 3)); var enumerable = lazy.Switch(); lazy.IsValueCreated.IsFalse(nameof(lazy.IsValueCreated)); var count = enumerable.Count(); lazy.IsValueCreated.IsTrue(nameof(lazy.IsValueCreated)); } } }