public void Optional_Bind_WithoutStringValue() { var optional = new Optional <string>(); Assert.False(optional.HasValue); var newOptional = optional.Bind <string>(some => "new_" + some); Assert.Equal(string.Empty, newOptional.GetValueOrDefault(string.Empty)); }
public void Optional_Bind_WithStringValue2() { Optional <string> optional = "text"; Assert.True(optional.HasValue); var newOptional = optional.Bind <string>(some => "new_" + some).Bind <string>(some => "new_" + some); Assert.Equal("new_new_text", newOptional.GetValueOrDefault(string.Empty)); }
public void Optional_Bind_WithoutClassValue() { var optional = new Optional <TestClass>(); Assert.False(optional.HasValue); var newOptional = optional.Bind <TestClass>(some => new TestClass { TestMessage = "new_" + some.TestMessage }); Assert.Null(newOptional.GetValueOrDefault(null)); }