public void when_ValidateProperty_is_called_then_ErrorsChanged_pumps() { var testSchedulerProvider = new TestDispatcherSchedulerProvider(); var rxTestScheduler = testSchedulerProvider.Current.RX as TestScheduler; var errorChangedPumped = false; var validatingObject = new ValidatingObject(); var sut = new ValidationAsync <ValidatingObject, ValidatingObjectValidator>(testSchedulerProvider); sut.Initialise(validatingObject); sut.ErrorsChanged .ObserveOn(rxTestScheduler) .Subscribe(_ => errorChangedPumped = true); Assert.That(errorChangedPumped, Is.False); sut.ValidateProperty(() => validatingObject.Name); rxTestScheduler.AdvanceBy(1); Assert.That(errorChangedPumped, Is.True); }
public void when_a_property_is_invalid_then_HasErrors_return_True() { var testSchedulerProvider = new TestDispatcherSchedulerProvider(); var validatingObject = new ValidatingObject(); var sut = new ValidationAsync <ValidatingObject, ValidatingObjectValidator>(testSchedulerProvider); sut.Initialise(validatingObject); sut.ValidateProperty(() => validatingObject.Name); Assert.That(sut.HasErrors, Is.True); }
public void when_a_property_is_invalid_then_GetErrors_return_the_correct_validation_results() { var testSchedulerProvider = new TestDispatcherSchedulerProvider(); var validatingObject = new ValidatingObject(); var sut = new ValidationAsync <ValidatingObject, ValidatingObjectValidator>(testSchedulerProvider); sut.Initialise(validatingObject); sut.ValidateProperty(() => validatingObject.Name); var validationResults = sut.GetErrors("Name").OfType <string>().ToList(); Assert.That(validationResults.Count(), Is.EqualTo(1)); Assert.That(validationResults[0], Is.EqualTo("'Name' must not be empty.")); }