Ejemplo n.º 1
0
        public void AggregateWithOptionsAndSeed()
        {
            var list = new[] { 1.AsOption(), 2.AsOption(), 3.AsOption() };

            var result = list.AggregateOrNone(10.AsOption(), (total, current) => total.SelectMany(t => current.Map(c => t + c)));

            Assert.That(result.ForceValue(), Is.EqualTo(16));
        }
Ejemplo n.º 2
0
        public void AggregateWithOptionsAndNoneAndSeed()
        {
            var list = new[] { 1.AsOption(), Option<int>.None, 3.AsOption() };

            var result = list.AggregateOrNone(10.AsOption(), (total, current) => total.SelectMany(t => current.Map(c => t + c)));

            Assert.That(!result.IsSome);
        }
Ejemplo n.º 3
0
        public void AggregateWithExistingMembersAndSeed()
        {
            var list = new[] { 1, 2, 3 };

            var result = list.AggregateOrNone(10, (total, current) => total + current);

            Assert.That(result.ForceValue(), Is.EqualTo(16));
        }