public void UnionMatch() { var match = new UnionMatcher<Union<string, StringBuilder>, string> { {UnionCase._<string>(), s => s}, {UnionCase._<StringBuilder>(), sb => sb.ToString()} }.ToFunc(); Assert.Equal("string", match("string")); Assert.Equal(new StringBuilder("string builder").ToString(), match(new StringBuilder("string builder"))); }
public void UnionMatch() { var match = new UnionMatcher<Union<string, StringBuilder>, string> { {UnionCase._<string>(), s => s}, {UnionCase._<StringBuilder>(), sb => sb.ToString()} }.ToFunc(); Assert.Equal("string", match("string")); Assert.Equal(new StringBuilder("string builder").ToString(), match(new StringBuilder("string builder"))); }