public void should_be_able_to_filter_selected_nodes_before_assertion() { Check.Result r = Check.That(subject).a[Should.Have(2).Where(v => v.x == "yes")]; Assert.That(r.Success, Is.True, r.Reason); }
public void should_be_able_to_filter_selected_nodes_before_assertion__failure_case() { Check.Result r = Check.That(subject).a[Should.Have(2).Where(v => v.x == "no")]; Assert.That(r.Success, Is.False); Assert.That(r.Reason, Is.StringContaining(".a should have 2 items exactly, but had 1")); }
public void fails_if_any_assertion_fails() { Check.Result result = Check.That(subject).Two.X[Should.Be <A>(), Should.Equal(subject.Two.X), Should.BeNull]; Console.WriteLine(string.Join(" ", result.Reasons)); Assert.That(result.Success, Is.False); }
public void can_mix_predicates_and_assertions() { var SaysHelloWorld = new NamedPredicate(o => (o as A).Value == "Hello, world", "Should greet the world"); Check.Result result = Check.That(subject).Two.X[Should.Be <A>(), SaysHelloWorld]; Assert.That(result.Success, Is.True); }
public void should_be_able_to_filter_selected_nodes_before_assertion_with_a_named_predicate() { var x_is_yes = Should.Be(v => ((dynamic)v).x == "yes", "x is yes"); Check.Result r = Check.That(subject).a[Should.Have(2).Where(x_is_yes)]; Assert.That(r.Success, Is.True, r.Reason); }
public void can_mix_predicates_and_assertions_with_failure() { var FrankieSaysRelax = new NamedPredicate(o => (o as A).Value == "Relax", "You should relax more"); Check.Result result = Check.That(subject).Two.X[Should.Be <A>(), FrankieSaysRelax]; Assert.That(result.Success, Is.False); Assert.That(result.Reasons, Contains.Item("BaseThing.Two.X You should relax more")); }
public void can_run_merge_results_to_check_any_pass() { Check.Result result1 = Check.That(subject).container(0).a[Should.BeTrue]; Check.Result result2 = Check.That(subject).container(1).a[Should.BeTrue]; Check.Result result3 = Check.That(subject).container(2).a[Should.BeTrue]; var result = result1.Or(result2.Or(result3)); Assert.That(result.Success, Is.True); Assert.That(result.Reason, Is.Empty); }
public void can_run_merge_results_to_check_all_pass() { Check.Result result1 = Check.That(subject).container(0).a[Should.BeTrue]; Check.Result result2 = Check.That(subject).container(1).a[Should.BeTrue]; Check.Result result3 = Check.That(subject).container(2).a[Should.BeTrue]; var result = result1.Merge(result2.Merge(result3)); Assert.That(result.Success, Is.False); Assert.That(result.Reason, Is.EqualTo("X.container[1].a expected True but got False")); }
public void should_be_able_to_filter_selected_nodes_before_assertion_with_a_named_predicate__failure_case() { var x_is_no = Should.Be(v => ((dynamic)v).x == "no", "x is no"); Check.Result r = Check.That(subject).a[Should.Have(2).Where(x_is_no)]; Console.WriteLine(r.Reason); Assert.That(r.Success, Is.False); Assert.That(r.Reason, Is.StringContaining(".a should have 2 items exactly, but had 1 where x is no")); }
public void Should_validate_when_date_is_before_other_date() { var obj = new { dates = new [] { new { Value = new DateTime(1980, 01, 01) } } }; Check.Result result = Check.That(obj).dates("all").Value[Should.BeBefore(new DateTime(2012, 01, 01))]; Assert.That(result.Success, Is.True, result.Reason); }
public void Should_fail_when_date_is_after_other_date() { var obj = new { dates = new List <DateTime> { new DateTime(1980, 01, 01), } }; var expectedDate = new DateTime(1012, 01, 01); Check.Result result = Check.That(obj).dates("all")[Should.BeBefore(expectedDate)]; Assert.That(result.Success, Is.False, result.Reason); Assert.That(result.Reason, Is.StringEnding("should be before " + expectedDate)); }
public void Should_be_able_to_check_dates_in_one_path_against_dates_in_another_path_passing() { var obj = new { earlier = new { date = new DateTime(1979, 01, 01) }, later = new { date = new DateTime(1980, 01, 01) } }; Check.Result result = Check.That(obj).earlier.date[Should.BeBefore(Check.That(obj).later.date)]; Console.WriteLine(result.Reason); Assert.That(result.Success, Is.True, result.Reason); }
public void Should_be_able_to_check_dates_in_one_path_against_dates_in_another_path_failing() { var obj = new { earlier = new { date = new DateTime(1980, 01, 01) }, later = new { date = new DateTime(1979, 01, 01) } }; Check.Result result = Check.That(obj).earlier.date[Should.BeBefore(Check.That(obj).later.date)]; Console.WriteLine(result.Reason); Assert.That(result.Success, Is.False, result.Reason); Assert.That(result.Reason, Is.StringContaining(".earlier.date should be before")); Assert.That(result.Reason, Is.StringEnding(".later.date")); }
public void Should_pass_null_or_before_validation_when_date_is_null() { var obj = new { earlier = new K { Date = null }, later = new K { Date = new DateTime(1979, 01, 01) } }; Check.Result result = Check.That(obj).earlier.Date[Should.BeNullOrBefore(Check.That(obj).later.Date)]; Console.WriteLine(result.Reason); Assert.That(result.Success, Is.True, result.Reason); }
public void assert_two_q_doesnt_exist() { Check.Result result = Check.That(subject).Two.Q.AnotherName.What.The.Fudge[Should.NotBeNull]; Assert.That(result.Success, Is.False); Assert.That(result.Reasons, Contains.Item("BaseThing.Two.Q is not a valid path")); }
public void can_use_more_than_one_assertion() { Check.Result result = Check.That(subject).Two.X[Should.Be <A>(), Should.Equal(subject.Two.X)]; Assert.That(result.Success, Is.True); }
public void assert_two_x_is_type_of_a() { Check.Result result = Check.That(subject).Two.X[Should.Be <A>()]; Assert.That(result.Success, Is.True); }
public void assert_two_y_is_null() { Check.Result result = Check.That(subject).Two.Y[Should.BeNull]; Assert.That(result.Success, Is.True); }