Ejemplo n.º 1
0
                public void Empty()
                {
                    var source = Empty <object>().Hide();

                    var(t, x) = source.LastOrNone(BreakingFunc.Of <object, bool>());
                    Assert.That(t, Is.False);
                    Assert.That(x, Is.Null);
                }
Ejemplo n.º 2
0
                public void Many()
                {
                    var source = MoreEnumerable.From(() => 123, BreakingFunc.Of <int>());

                    var(t, x) = source.FirstOrNone();
                    Assert.That(t, Is.True);
                    Assert.That(x, Is.EqualTo(123));
                }
Ejemplo n.º 3
0
 public void ManyMatch()
 {
     var(t, x) =
         Source.Concat(MoreEnumerable.From(BreakingFunc.Of <int>()))
         .SingleOrNone(x => x > 200);
     Assert.That(t, Is.False);
     Assert.That(x, Is.Zero);
 }
Ejemplo n.º 4
0
                public void Many()
                {
                    var source = MoreEnumerable.From(() => 123, () => 456, BreakingFunc.Of <object>());

                    var(t, x) = source.SingleOrNone();
                    Assert.That(t, Is.False);
                    Assert.That(x, Is.Null);
                }
Ejemplo n.º 5
0
                public void NullSource()
                {
                    var e = Assert.Throws <ArgumentNullException>(() =>
                                                                  Enumerable.LastOrNone(null, BreakingFunc.Of <object, bool>()));

                    Assert.That(e.ParamName, Is.EqualTo("source"));
                }
Ejemplo n.º 6
0
        public void MatchWithNullSomeFunction(bool f, int v)
        {
            var e = Assert.Throws <ArgumentNullException>(() =>
                                                          Option.From(f, v).Match(null, BreakingFunc.Of <_>()));

            Assert.That(e.ParamName, Is.EqualTo("some"));
        }