public void Supply() { Nullable <int> n = 2; Nullable <int> n0 = null; Assert.Throws <ArgumentNullException>(() => NullableExtensions.Supply <int>(n, null)); Assert.True(n.Supply(() => 1).HasValue); Assert.True(n0.Supply(() => 1).HasValue); Assert.Equal(2, n.Supply(() => 1).Value); Assert.Equal(1, n0.Supply(() => 1).Value); // not called Assert.True(n.Supply(() => throw new InvalidOperationException("Shpuld not be called")).HasValue); }