예제 #1
0
        public static object[][] PassingConstraints() => new object[][]
        {
            new object[] { AtLeast.Once(), 1 },
            new object[] { AtLeast.Once(), 2 },
            new object[] { AtLeast.Twice(), 2 },
            new object[] { AtLeast.Twice(), 3 },
            new object[] { AtLeast.Thrice(), 3 },
            new object[] { AtLeast.Thrice(), 4 },
            new object[] { AtLeast.Times(4), 4 },
            new object[] { AtLeast.Times(4), 5 },

            new object[] { AtMost.Once(), 0 },
            new object[] { AtMost.Once(), 1 },
            new object[] { AtMost.Twice(), 1 },
            new object[] { AtMost.Twice(), 2 },
            new object[] { AtMost.Thrice(), 2 },
            new object[] { AtMost.Thrice(), 3 },
            new object[] { AtMost.Times(4), 3 },
            new object[] { AtMost.Times(4), 4 },

            new object[] { Exactly.Once(), 1 },
            new object[] { Exactly.Twice(), 2 },
            new object[] { Exactly.Thrice(), 3 },
            new object[] { Exactly.Times(4), 4 },

            new object[] { LessThan.Twice(), 1 },
            new object[] { LessThan.Thrice(), 2 },
            new object[] { LessThan.Times(4), 3 },

            new object[] { MoreThan.Once(), 2 },
            new object[] { MoreThan.Twice(), 3 },
            new object[] { MoreThan.Thrice(), 4 },
            new object[] { MoreThan.Times(4), 5 },
        };
예제 #2
0
 public void CadenaConMasDeUnaOcurrencia()
 {
     _cadenaNoVacioXL.Should().Contain("pero", MoreThan.Twice());
     _cadenaNoVacioXL.Should().Contain("pero", MoreThan.Times(2));
     _cadenaNoVacioXL.Should().Contain("pero", Exactly.Times(3));
     _cadenaNoVacioXL.Should().Contain("pero", Exactly.Thrice());
 }
                public void When_string_containment_more_than_is_asserted_and_actual_value_contains_the_expected_string_more_than_expected_times_it_should_not_throw()
                {
                    // Arrange
                    string actual            = "ABCDEBCDF";
                    string expectedSubstring = "BCD";

                    // Act
                    Action act = () => actual.Should().Contain(expectedSubstring, MoreThan.Times(1));

                    // Assert
                    act.Should().NotThrow();
                }
                public void When_string_containment_more_than_is_asserted_and_actual_value_contains_the_expected_string_but_not_more_than_expected_times_it_should_throw()
                {
                    // Arrange
                    string actual            = "ABCDEBCDF";
                    string expectedSubstring = "BCD";

                    // Act
                    Action act = () => actual.Should().Contain(expectedSubstring, MoreThan.Times(2));

                    // Assert
                    act.Should().Throw <XunitException>()
                    .WithMessage("Expected * \"ABCDEBCDF\" to contain \"BCD\" more than 2 times, but found it 2 times.");
                }