コード例 #1
0
        public void An_enum_that_is_one_of_the_expected_values_should_not_throw()
        {
            // Arrange
            BindingFlags flags = BindingFlags.Public;

            // Act / Assert
            flags.Should().BeOneOf(BindingFlags.Public, BindingFlags.ExactBinding);
        }
コード例 #2
0
        public void An_enum_matching_the_predicate_should_not_throw()
        {
            // Arrange
            BindingFlags flags = BindingFlags.Public;

            // Act / Assert
            flags.Should().Match(x => x == BindingFlags.Public);
        }
コード例 #3
0
        public void An_enum_not_matching_the_predicate_should_throw_with_the_predicate_in_the_message()
        {
            // Arrange
            BindingFlags flags = BindingFlags.Public;

            // Act
            Action act = () => flags.Should().Match(x => x == BindingFlags.Static, "that's what we need");

            // Assert
            act.Should().Throw <XunitException>().WithMessage("Expected*Static*because that's what we need*found*Public*");
        }
コード例 #4
0
        public void An_enum_cannot_be_part_of_a_null_list()
        {
            // Arrange
            BindingFlags flags = BindingFlags.DeclaredOnly;

            // Act / Assert
            Action act = () => flags.Should().BeOneOf(null);

            act.Should()
            .Throw <ArgumentException>()
            .WithMessage("Cannot*null list of enums*");
        }
コード例 #5
0
        public void Throws_when_the_enums_is_not_one_of_the_expected_enums()
        {
            // Arrange
            BindingFlags flags = BindingFlags.DeclaredOnly;

            // Act / Assert
            Action act = () => flags.Should().BeOneOf(new[] { BindingFlags.Public, BindingFlags.ExactBinding }, "that's what we need");

            act.Should()
            .Throw <XunitException>()
            .WithMessage("Expected*Public*ExactBinding*because that's what we need*found*DeclaredOnly*");
        }