예제 #1
0
        public void First_With_Empty_Must_Throw(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueReadOnlyCollection(source);

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

            // Assert
            _ = action.Must()
                .Throw <InvalidOperationException>()
                .EvaluateTrue(exception => exception.Message == "Sequence contains no elements");
        }
예제 #2
0
        public void First_With_Empty_Must_Return_None(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueReadOnlyCollection(source);

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

            // Assert
            _ = result.Must()
                .BeOfType <Option <int> >()
                .EvaluateTrue(option => option.IsNone);
        }
예제 #3
0
        public void First_With_ValidData_Must_Succeed(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueReadOnlyCollection(source);
            var expected =
                System.Linq.Enumerable.First(source);

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

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
예제 #4
0
        public void First_With_ValidData_Must_Return_Some(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueReadOnlyCollection(source);
            var expected =
                System.Linq.Enumerable.First(source);

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

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