public void FirstOrDefault_With_ValidData_Must_Succeed(int[] source)
        {
            // Arrange
            var wrapped = Wrap
                          .AsValueReadOnlyList(source);
            var expected =
                System.Linq.Enumerable.FirstOrDefault(source);

            // Act
            var result = ReadOnlyList
                         .FirstOrDefault <Wrap.ValueReadOnlyList <int>, int>(wrapped);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
Beispiel #2
0
        public void List_FirstOrDefault()
        {
            var list = new int[] { };

            Assert.AreEqual(0, ReadOnlyList.FirstOrDefault(list));
            list = new int[] { 3 };
            Assert.AreEqual(3, ReadOnlyList.FirstOrDefault(list));
            list = new int[] { 9, 3, 1 };
            Assert.AreEqual(9, ReadOnlyList.FirstOrDefault(list));
            var list2 = new string[] { };

            Assert.AreEqual((string)null, ReadOnlyList.FirstOrDefault(list2));
            list2 = new string[] { "one" };
            Assert.AreEqual("one", ReadOnlyList.FirstOrDefault(list2));
            list2 = new string[] { "three", "two", "one" };
            Assert.AreEqual("three", ReadOnlyList.FirstOrDefault(list2));
        }