public void Should_invoke_validate_on_instance() { // Given var instance = new ModelUnderTest(); // When this.validator.Validate(instance, new NancyContext()); // Then instance.ValidatedWasInvoked.ShouldBeTrue(); }
public void Should_invoke_validate_with_instance() { // Given var instance = new ModelUnderTest(); // When this.validator.Validate(instance, new NancyContext()); // Then instance.InstanceBeingValidated.ShouldBeSameAs(instance); }
public void Should_invoke_validatable_object_adapter_with_instance_being_validated() { // Given var instance = new ModelUnderTest(); // When this.validator.Validate(instance); // Then A.CallTo(() => this.validatableObjectAdapter.Validate(instance)).MustHaveHappened(); }
public void Should_get_property_validators_from_factory() { // Given var instance = new ModelUnderTest(); // When this.validator.Validate(instance); // Then A.CallTo(() => this.validatorFactory.GetValidators(typeof(ModelUnderTest))).MustHaveHappened(); }
public void Should_invoke_validatable_object_adapter_with_instance_being_validated() { // Given var instance = new ModelUnderTest(); // When this.validator.Validate(instance, new NancyContext()); // Then A.CallTo(() => this.validatableObjectAdapter.Validate(instance)).MustHaveHappened(); }
public void Should_get_property_validators_from_factory() { // Given var instance = new ModelUnderTest(); // When this.validator.Validate(instance, new NancyContext()); // Then A.CallTo(() => this.validatorFactory.GetValidators(typeof(ModelUnderTest))).MustHaveHappened(); }
public void Should_invoke_all_validators_returned_by_factory_with_instance_being_validated() { // Given var instance = new ModelUnderTest(); // When this.validator.Validate(instance); // Then A.CallTo(() => this.propertyValidator1.Validate(instance)).MustHaveHappened(); A.CallTo(() => this.propertyValidator2.Validate(instance)).MustHaveHappened(); }
public void Should_invoke_all_validators_returned_by_factory_with_instance_being_validated() { // Given var instance = new ModelUnderTest(); // When this.validator.Validate(instance, new NancyContext()); // Then A.CallTo(() => this.propertyValidator1.Validate(instance)).MustHaveHappened(); A.CallTo(() => this.propertyValidator2.Validate(instance)).MustHaveHappened(); }
public void Should_contain_validation_result_from_validatable_object_adapter() { // Given var instance = new ModelUnderTest(); var result = new ModelValidationError(string.Empty, x => string.Empty); A.CallTo(() => this.validatableObjectAdapter.Validate(instance)).Returns(new[] { result }); // When var results = this.validator.Validate(instance); // Then results.Errors.Count().ShouldEqual(1); results.Errors.Contains(result).ShouldBeTrue(); }
public void Should_contain_validation_result_from_validatable_object_adapter() { // Given var instance = new ModelUnderTest(); var result = new ModelValidationError(string.Empty, x => string.Empty); A.CallTo(() => this.validatableObjectAdapter.Validate(instance)).Returns(new[] { result }); // When var results = this.validator.Validate(instance, new NancyContext()); // Then results.Errors.Count().ShouldEqual(1); results.Errors.Contains(result).ShouldBeTrue(); }
public void Should_return_validation_error_for_all_validation_results() { // Given var result1 = new ValidationResult("Error1", new[] { "foo" }); var result2 = new ValidationResult("Error2", new[] { "bar", "baz" }); var instance = new ModelUnderTest { ExpectedResults = new[] { result1, result2 } }; // When var results = this.validator.Validate(instance, new NancyContext()); // Then results.Count().ShouldEqual(2); }
public void Should_return_validation_error_for_all_validation_results() { // Given var result1 = new ValidationResult("Error1", new[] { "foo" }); var result2 = new ValidationResult("Error2", new[] { "bar", "baz" }); var instance = new ModelUnderTest { ExpectedResults = new[] {result1, result2} }; // When var results = this.validator.Validate(instance, new NancyContext()); // Then results.Count().ShouldEqual(2); }
public void Should_contain_validation_results_from_all_validators() { // Given var instance = new ModelUnderTest(); var result1 = new ModelValidationError("Foo", string.Empty); var result2 = new ModelValidationError("Bar", string.Empty); var result3 = new ModelValidationError("Baz", string.Empty); A.CallTo(() => this.propertyValidator1.Validate(instance)).Returns(new[] { result1 }); A.CallTo(() => this.propertyValidator2.Validate(instance)).Returns(new[] { result2, result3 }); // When var results = this.validator.Validate(instance, new NancyContext()); // Then results.Errors.Count().ShouldEqual(3); }