예제 #1
0
        public void Where()
        {
            Assert.Equal(42, Success.Where(i => i > 40, _ => Exception).Get());
            Assert.Throws <NotImplementedException>(() => Success.Where(i => i > 50, _ => Exception).Get());
            Assert.Throws <NotImplementedException>(() => Error.Where(i => i > 40, _ => Exception).Get());
            Assert.Throws <NotImplementedException>(() => Error.Where(i => i > 50, _ => Exception).Get());

            var success = Try.Success <int, IEnumerable <NotImplementedException> >(42);
            var error   = Try.Error <int, IEnumerable <NotImplementedException> >(new[] { Exception });

            Assert.Equal(42, success.Where(i => i > 40, _ => Exception).Get(e => e.First()));
            Assert.Throws <NotImplementedException>(() => success.Where(i => i > 50, _ => Exception).Get(e => e.First()));
            Assert.Throws <NotImplementedException>(() => error.Where(i => i > 40, _ => Exception).Get(e => e.First()));
            Assert.Throws <NotImplementedException>(() => error.Where(i => i > 50, _ => Exception).Get(e => e.First()));
        }