public void When_collection_is_IEnumerable_it_should_be_evaluated_only_once()
        {
            // Arrange
            IEnumerable <int> collection = new OneTimeEnumerable <int>(1);

            // Act
            Action act = () => collection.Should().ContainSingle();

            // Assert
            act.Should().NotThrow();
        }
Beispiel #2
0
        public void When_a_collection_does_not_contain_the_unexpected_items_it_should_not_be_enumerated_twice()
        {
            // Arrange
            var collection = new OneTimeEnumerable <int>(1, 2, 3);

            // Act
            Action act = () => collection.Should().OnlyContain(i => i > 3);

            // Assert
            act.Should().Throw <XunitException>().WithMessage(
                "Expected collection to contain only items matching*");
        }
            public void When_a_collection_contains_the_unexpected_item_it_should_not_be_enumerated_twice()
            {
                // Arrange
                var collection = new OneTimeEnumerable <int>(1, 2, 3);

                // Act
                Action act = () => collection.Should().NotContain(2);

                // Assert
                act.Should().Throw <XunitException>().WithMessage(
                    "Expected collection*to not contain 2.");
            }