public void ForCharacteraandStringnullShouldReturnnull() { var a = new IOptional(new Character('a')); IMatch actual = a.Match(null); Assert.Null(actual.RemainingText()); }
public void ForCharacterMinusandString123ShouldReturntrue() { var sign = new IOptional(new Character('-')); IMatch actual = sign.Match("123"); Assert.True(actual.Succes()); }
public void ForCharacteraandStringnullShouldReturnTrue() { var a = new IOptional(new Character('a')); IMatch actual = a.Match(null); Assert.True(actual.Succes()); }
public void ForCharacterAAndStringAbcShouldReturnTrue() { IOptional a = new IOptional(new Character('a')); IMatch actual = a.Match(Text); Assert.True(actual.Succes()); }
public void ForCharacteraandStringEmptyStringShouldReturnEmptyString() { var a = new IOptional(new Character('a')); IMatch actual = a.Match(string.Empty); Assert.Equal(string.Empty, actual.RemainingText()); }
public void ForCharacteraandStringbcShouldReturnbc() { var a = new IOptional(new Character('a')); IMatch actual = a.Match("bc"); Assert.Equal("bc", actual.RemainingText()); }
public void ForCharacterMinusandStringMinus123ShouldReturn123() { var a = new IOptional(new Character('-')); IMatch actual = a.Match("-123"); Assert.Equal("123", actual.RemainingText()); }
public static TValue GetValue <TValue>(this IOptional <TValue> optional) { return(optional.Match( exists: val => val, nothing: () => { throw new Exception("Cannot get value on Nothing"); })); }
public static Boolean HasValue <TValue>(this IOptional <TValue> optional) { return(optional.Match( exists: val => true, nothing: () => false)); }