Beispiel #1
0
        public void BasicTest()
        {
            Check.That("Unit").IsNotEmpty();

            Check.ThatCode(() => Check.That("Unit").IsEqualTo("great")).Throws <AssertionException>();
            Check.ThatCode(() => Assuming.That("Unit").IsEqualTo("great")).Throws <InconclusiveException>();
        }
Beispiel #2
0
        public void ProvideIgnoreForDynamic()
        {
            dynamic test = 2;

            Assuming.ThatDynamic(test).IsNotNull();
            test = null;
            Check.ThatCode(() => Assuming.ThatDynamic(test).IsNotNull()).IsAFailingAssumption();
        }
Beispiel #3
0
 public void ProvideIgnoreWithCustomMessage()
 {
     Check.ThatCode(() => Assuming.WithCustomMessage("it works").That(12).IsEqualTo(13)).
     IsAFailingAssumptionWithMessage("it works",
                                     "The checked value is different from the expected one.",
                                     "The checked value:",
                                     "\t[12]",
                                     "The expected value:",
                                     "\t[13]");
 }
Beispiel #4
0
        public void IsAFailingAssumptionReportsProperError()
        {
            Check.ThatCode(() => Assuming.ThatCode(() => 0).IsAFailingCheckWithMessage("don't care"))
            .IsAFailingAssumptionWithMessage("",
                                             "The check succeeded whereas it should have failed.",
                                             "The expected fluent check's raised exception:",
                                             Criteria.FromRegEx("\tan instance of .*"));

            Check.ThatCode(() =>
                           // check with an incomplete error message
                           Check.ThatCode(() => throw ExceptionHelper.BuildInconclusiveException("oups"))
                           .IsAFailingAssumptionWithMessage("oups", "and more")
                           ).IsAFailingCheckWithMessage("",
                                                        "Lines are missing in the error message starting at #1",
                                                        "The checked fluent assumption's raised exception's error message:",
                                                        "\t{\"oups\"} (1 item)",
                                                        "The expected fluent assumption's raised exception's error message:",
                                                        "\t{\"oups\", \"and more\"} (2 items)");

            Check.ThatCode(() =>
                           // check with an incorrect error message
                           Check.ThatCode(() => throw ExceptionHelper.BuildInconclusiveException("oups"))
                           .IsAFailingAssumptionWithMessage("oupsla")
                           ).IsAFailingCheckWithMessage("",
                                                        "Line 0 is different from what is expected",
                                                        "Act:oups",
                                                        "Exp:\"oupsla\"",
                                                        "The checked fluent assumption's raised exception's error message:",
                                                        "\t{\"oups\"} (1 item)",
                                                        "The expected fluent assumption's raised exception's error message:",
                                                        "\t{\"oupsla\"} (1 item)");

            Check.ThatCode(() =>
                           // check with a error message that is too long
                           Check.ThatCode(() => throw ExceptionHelper.BuildInconclusiveException("oups" + Environment.NewLine + "and more"))
                           .IsAFailingAssumptionWithMessage("oupsla")
                           ).IsAFailingCheck();
            // can use regular expression.
            Check.ThatCode(() => throw ExceptionHelper.BuildInconclusiveException("oups")).
            IsAFailingAssumptionWithMessage(Criteria.FromRegEx("[pous]+"));
            Check.ThatCode(() =>
                           // check with a error message that is too long
                           Check.ThatCode(() => throw ExceptionHelper.BuildInconclusiveException("oups" + Environment.NewLine + "and more"))
                           .IsAFailingAssumptionWithMessage(Criteria.FromRegEx("[pous]+"))
                           ).IsAFailingCheckWithMessage("",
                                                        "Too many lines in the error message starting at #1",
                                                        "The checked fluent assumption's raised exception's error message:",
                                                        "\t{\"oups\", \"and more\"} (2 items)",
                                                        "The expected fluent assumption's raised exception's error message:",
                                                        "\t{matches: [pous]+} (1 item)");
            Check.ThatCode(() =>
                           // check with a error message that does not match regex
                           Check.ThatCode(() => throw ExceptionHelper.BuildInconclusiveException("oupsla"))
                           .IsAFailingAssumptionWithMessage(Criteria.FromRegEx("[pous]+$"))
                           ).IsAFailingCheckWithMessage("",
                                                        "Line 0 is different from what is expected",
                                                        "Act:oupsla",
                                                        "Exp:matches: [pous]+$",
                                                        "The checked fluent assumption's raised exception's error message:",
                                                        "\t{\"oupsla\"} (1 item)",
                                                        "The expected fluent assumption's raised exception's error message:",
                                                        "\t{matches: [pous]+$} (1 item)");

            Check.ThatCode(() =>
                           // check with a error message that is too long
                           Check.ThatCode(() => throw new Exception("oups"))
                           .IsAFailingAssumptionWithMessage(Criteria.FromRegEx("[pous]+"))
                           ).IsAFailingCheckWithMessage("",
                                                        "The exception raised is not of the expected type.",
                                                        "The checked fluent assumption's raised exception:",
                                                        "\t[{System.Exception}: 'oups'] of type: [System.Exception]",
                                                        "The expected fluent assumption's raised exception:",
                                                        "#\tan instance of .*");
        }
Beispiel #5
0
 public void AssumptionScanTest()
 {
     Assuming.That(2).IsEqualTo(2);
     Check.ThatCode(() => Assuming.That(2).IsEqualTo(0)).Throws <XunitException>();
     Check.ThatCode(() => Assuming.That(2).IsEqualTo(0)).IsAFailingAssumption();
 }
Beispiel #6
0
 public void AssumptionTest()
 {
     Check.ThatCode(() => Assuming.That("MsTest").IsEqualTo("great")).Throws <AssertInconclusiveException>();
 }
Beispiel #7
0
 private static void AssumptionTest()
 {
     Check.ThatCode(() => Assuming.That(2).IsEqualTo(3)).Throws <FluentCheckException>();
     Check.ThatCode(() => Assuming.That(2).IsEqualTo(3)).IsAFailingAssumption();
 }
Beispiel #8
0
 public void ProvideIgnoreForObjectCheck()
 {
     Assuming.That(12).IsEqualTo(12);
     Check.ThatCode(() => Assuming.That(12).IsEqualTo(13)).IsAFailingAssumption();
 }
Beispiel #9
0
 public void ProvideIgnoreForCode()
 {
     Assuming.ThatCode(() => 2).DoesNotThrow();
     Assuming.ThatCode(() => {}).DoesNotThrow();
     Check.ThatCode(() => Assuming.ThatCode(() => 2).ThrowsAny()).IsAFailingAssumption();
 }
Beispiel #10
0
 public void ProvideIgnoreForStructCheck()
 {
     Assuming.ThatEnum(4).IsEqualTo(4);
     Check.ThatCode(() => Assuming.ThatEnum(4).IsEqualTo(5)).IsAFailingAssumption();
 }
Beispiel #11
0
 public void ProvideIgnoreForTypeCheck()
 {
     Assuming.That <int>().IsEqualTo(typeof(int));
     Check.ThatCode(() => Assuming.That <int>().IsInstanceOf <int>()).IsAFailingAssumption();
 }
Beispiel #12
0
 public void AssumptionScanTest()
 {
     // inject a type from the fuzzing assembly to check for some degenerative case
     Assuming.That(2).IsEqualTo(2);
     Assuming.ThatCode(() => Check.That(2).IsEqualTo(0)).Throws <XunitException>();
 }