Esempio n. 1
0
        public void Single_With_Multiple_Must_Return_None(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueEnumerable(source);

            // Act
            var result = ValueEnumerable
                         .Single <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped);

            // Assert
            _ = result.Must()
                .BeOfType <Option <int> >()
                .EvaluateTrue(option => option.IsNone);
        }
        public void Single_With_Multiple_Must_Throw(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueEnumerable(source);

            // Act
            Action action = () => _ = ValueEnumerable
                                      .Single <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped);

            // Assert
            _ = action.Must()
                .Throw <InvalidOperationException>()
                .EvaluateTrue(exception => exception.Message == "Sequence contains more than one element");
        }
        public void Single_With_Single_Must_Succeed(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueEnumerable(source);
            var expected =
                System.Linq.Enumerable.Single(source);

            // Act
            var result = ValueEnumerable
                         .Single <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
Esempio n. 4
0
        public void Single_With_Single_Must_Return_Some(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueEnumerable(source);
            var expected =
                System.Linq.Enumerable.Single(source);

            // Act
            var result = ValueEnumerable
                         .Single <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped);

            // Assert
            _ = result.Match(
                value => value.Must().BeEqualTo(expected),
                () => throw new Exception());
        }