public void the_return_cell_is_marked_as_output() { ShouldBeTestExtensions.ShouldBe(ValueCheckMethod .For(new Target(), x => x.Fullname2(null, null)) .ReturnCell .output, true); }
public void the_return_cell_is_marked_as_output() { ValueCheckMethod .For(new Target(), x => x.Fullname2(null, null)) .ReturnCell .result.ShouldBe(true); }
public void derived_format_has_the_return_value_too() { ValueCheckMethod .For(new Target(), x => x.Fullname3(null, null)) .Compile(new Fixture(), CellHandling.Basic()) .ShouldBeOfType <Sentence>() .format.ShouldBe("Fullname3({first}, {last}) should be {returnValue}"); }
public void format_from_attribute_if_it_exists() { ValueCheckMethod .For(new Target(), x => x.Fullname(null, null)) .Compile(new Fixture(), CellHandling.Basic()) .ShouldBeOfType <Sentence>() .format.ShouldBe("The fullname for {first} & {second} should be {expected}"); }
public void execute_the_method_with_a_step_and_store_the_actual() { MethodInfo method = ReflectionHelper.GetMethod <ReflectionTarget>(x => x.GetNameAndAge("", 0)); var grammar = new ValueCheckMethod(method, new ReflectionTarget()); Step step = new Step("a").With("name", "Jeremy").With("age", 34); grammar.Execute(step).Results.ActualDisplay <string>(method.GetReturnValueAlias()).ShouldEqual("Jeremy is 34"); }
public void select_return_att_name_by_last_key() { var returnCell = ValueCheckMethod .For(new Target(), x => x.Fullname(null, null)) .ReturnCell; returnCell.Key.ShouldBe("expected"); returnCell.Type.ShouldBe(typeof(string)); }
public void select_return_att_name_by_explicit_attribute() { var returnCell = ValueCheckMethod .For(new Target(), x => x.Fullname2(null, null)) .ReturnCell; returnCell.Key.ShouldBe("fullname"); returnCell.Type.ShouldBe(typeof(string)); }
public void select_return_att_name_by_default() { var returnCell = ValueCheckMethod .For(new Target(), x => x.Fullname3(null, null)) .ReturnCell; // Hate this, but it's backward compatible returnCell.Key.ShouldBe("returnValue"); returnCell.Type.ShouldBe(typeof(string)); }
public void create_a_grammar_structure() { MethodInfo method = ReflectionHelper.GetMethod <ReflectionTarget>(x => x.GetNameAndAge("", 0)); var grammar = new ValueCheckMethod(method, new ReflectionTarget()); var sentence = grammar.ToStructure(new FixtureLibrary()).ShouldBeOfType <Sentence>(); sentence.ShouldEqual(Sentence.For(method.GetTemplate(), Cell.For <string>("name"), Cell.For <int>("age"), Cell.For <string>("theValue"))); }
public void make_the_last_parameter_the_output_cell_if_not_aliased() { MethodInfo method = ReflectionHelper.GetMethod <ReflectionTarget>(x => x.Adding(0, 0)); var grammar = new ValueCheckMethod(method, new ReflectionTarget()); var sentence = grammar.ToStructure(new FixtureLibrary()).ShouldBeOfType <Sentence>(); sentence.AllErrors().Any().ShouldBeFalse(); sentence.Cells.FirstOrDefault(x => x.IsResult).Key.ShouldEqual("sum"); }
public void marks_the_testdata_with_wrong_if_the_actual_is_wrong() { MethodInfo method = ReflectionHelper.GetMethod <ReflectionTarget>(x => x.GetNameAndAge("", 0)); var grammar = new ValueCheckMethod(method, new ReflectionTarget()); Step step = new Step("a").With("name", "Jeremy").With("age", 34).With("theValue", "the wrong value"); var data = new TestContext(); grammar.Execute(step, data); data.Counts.Wrongs.ShouldEqual(1); }
public void execute_happy() { var grammar = ValueCheckMethod.For(new Target(), x => x.Fullname(null, null)); var values = new StepValues("1"); values.Store("first", "Mat"); values.Store("last", "Cauthon"); values.Store("expected", "Mat Cauthon"); var context = SpecContext.ForTesting(); var result = grammar.Execute(values, context).Single(); result.cell.ShouldBe("expected"); result.Status.ShouldBe(ResultStatus.success); }
public void execute_sad() { var grammar = ValueCheckMethod.For(new Target(), x => x.Fullname(null, null)); var values = new StepValues("1"); values.Store("first", "Mat"); values.Store("last", "Cauthon"); values.Store("expected", "Rand Al'Thor"); var context = SpecContext.ForTesting(); var result = grammar.Execute(values, context).Single(); // The method is working correctly, but the // test data should result in a failure result.cell.ShouldBe("expected"); result.actual.ShouldBe("Mat Cauthon"); result.Status.ShouldBe(ResultStatus.failed); }