Example #1
0
        public async Task ClearValue_Should_Reset_Value()
        {
            // Arrange
            var counter = 0;

            async Task <int> ValueFactory() => await Task.Run(() => ++ counter);

            var lazy = new AsyncLazy <int>(ValueFactory);

            var initialValue = await lazy.GetValueAsync();

            // Act
            lazy.ClearValue();

            // Assert
            var value = await lazy.GetValueAsync();

            Assert.AreEqual(1, initialValue);
            Assert.AreEqual(2, value);
        }