Пример #1
0
        public void SingleOrDefault_With_Multiple_Must_Throw(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueEnumerable(source);

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

            // Assert
            _ = action.Must()
                .Throw <InvalidOperationException>()
                .EvaluateTrue(exception => exception.Message == "Sequence contains more than one element");
        }
Пример #2
0
        public void SingleOrDefault_With_EmptyOrSingle_Must_Succeed(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueEnumerable(source);
            var expected =
                System.Linq.Enumerable.SingleOrDefault(source);

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

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }