public void CauseValidationToSucceedGivenValidNumericString(string validNumericString) { var entity = new ValidatableEntity { MaximumStringOf5Property = validNumericString }; var validationResults = entity.Validate(); Assert.IsTrue(validationResults.Count == 0); }
public void CauseValidationToSucceedGivenAlphaPlusSpaceWithNoLeadingNoTrailing(string validValue) { var validatableEntity = new ValidatableEntity { AlphaPlusWithNoLeadingNoTrailing = validValue }; Assert.IsTrue(validatableEntity.Validate().Count == 0); }
public void CauseValidationToFailGivenAlphaPlusWithInvalidCharacters(string invalidValue) { var validatableEntity = new ValidatableEntity { AlphaPlusWithNoLeadingNoTrailing = invalidValue }; Assert.IsFalse(validatableEntity.Validate().Count == 0); }
public void CauseValidationToSucceedGivenAValidNumericString(string validNumericString) { var entity = new ValidatableEntity { NumericProperty = validNumericString }; Assert.IsTrue(entity.Validate().Count == 0); }
public void CauseValidationToSucceedGivenValidNumericStringWithExtraCharacters(string validNumericString) { var entity = new ValidatableEntity { NumericPlusAbcProperty = validNumericString }; Assert.IsTrue(entity.Validate().Count == 0); }
public void CauseValidationToSucceedGivenAValidNumber(int validNumber) { var entity = new ValidatableEntity { MinimumIntOf5Property = validNumber }; Assert.IsTrue(entity.Validate().Count == 0); }
public void CauseValidationToFailGivenAnInvalidNumericString(string invalidNumericString) { var entity = new ValidatableEntity { NumericProperty = invalidNumericString }; Assert.IsTrue(entity.Validate().Count > 0); }
public void CauseValidationToSucceedGivenExtraCharacters(string validValue) { var validatableEntity = new ValidatableEntity { AlphaPlusProperty = validValue }; Assert.IsTrue(validatableEntity.Validate().Count == 0); }
public void CauseValidationToFailGivenNonNumericString(string nonNumericString) { var entity = new ValidatableEntity { MinimumStringOf5Property = nonNumericString }; Assert.IsTrue(entity.Validate().Count > 0); }
public void ReturnFalseGivenInvalidStringForAlPhaPlusProperty(string validValue) { var validatableEntity = new ValidatableEntity { AlphaPlusProperty = validValue }; Assert.False(validatableEntity.IsValid()); }
public void CauseValidationToSucceedGivenValidNumericString(string validNumericString) { var entity = new ValidatableEntity { MinimumStringOf5Property = validNumericString }; var validationResults = entity.Validate(); Assert.IsTrue(validationResults.Count == 0); }
public void ReturnValidationResultsWithMemberNameGivenInvalidNumericString(string invalidNumericString) { var entity = new ValidatableEntity { NumericProperty = invalidNumericString }; List <ValidationResult> results = entity.Validate(); // The NumericProperty is causing the failure so that property should be included in the MemberNames... ValidationResult result = results.FirstOrDefault(r => r.MemberNames.Contains("NumericProperty")); Assert.IsTrue(result.IsNotNull()); }
public void ReturnValidationResultsWithMemberNameGivenInvalidNumber(int invalidNumber) { var entity = new ValidatableEntity { MinimumIntOf5Property = invalidNumber }; var results = entity.Validate(); // The NumericProperty is causing the failure so that property should be included in the MemberNames... var result = results.FirstOrDefault(r => r.MemberNames.Contains("MinimumIntOf5Property")); Assert.IsTrue(result.IsNotNull()); }
public void ReturnValidationResults() { // Arrange var entityId = Guid.NewGuid().ToString(); var invalidEntity = new ValidatableEntity { NumericProperty = "ABC" }; var exception = new LeadPipeNetInvalidEntityException("This is a test.", entityId, invalidEntity.Validate()); // Act var validationResults = exception.GetValidationResultsAsList(); // Assert Assert.IsNotNull(validationResults.FirstOrDefault(x => x.Key.Equals("NumericProperty"))); }
protected override void OnSaveChangesCommand(ValidatableEntity entity) { var link = entity as Link; if (link != null) { link.Category = SelectedCategory; base.OnSaveChangesCommand(entity); } }
protected async void OnDeleteCommand(ValidatableEntity entity) { DisableForm(); Debug.WriteLine(" === DialogViewModelBase_OnDeleteCommand"); int taskResult; using (var repo = Autofac.Resolve<ILinkRepositoryAsync>()) { //This is a simple add since we don't have it in db. Debug.WriteLine(" Deleting entry {0} ...", entity.Id); taskResult = await repo.DeleteAsync(entity); if (taskResult > 0) UpdateUi(GuiAction.Remove); } Debug.WriteLine(" Task result: " + taskResult); ValidateForm(); }
public void ReturnValidationResultsWithMemberNameGivenInvalidNumericString(string invalidNumericString) { var entity = new ValidatableEntity { NumericProperty = invalidNumericString }; List<ValidationResult> results = entity.Validate(); // The NumericProperty is causing the failure so that property should be included in the MemberNames... ValidationResult result = results.FirstOrDefault(r => r.MemberNames.Contains("NumericProperty")); Assert.IsTrue(result.IsNotNull()); }
protected virtual async void OnSaveChangesCommand(ValidatableEntity entity) { DisableForm(); Debug.WriteLine(" === DialogViewModelBase_OnSaveChangesCommand"); int taskResult; //entity.Updated = DateTime.Now; using (var repo = Autofac.Resolve<ILinkRepositoryAsync>()) { if (entity.Id > 0) { // Id already assigned, need to update. Debug.WriteLine(" Updating entry ..."); taskResult = await repo.UpdateAsync(entity); } else { //This is a simple add since we don't have it in db. Debug.WriteLine(" Creating new entry ..."); //entity.Created = DateTime.Now; taskResult = await repo.CreateAsync(entity); UpdateUi(GuiAction.Add); } } Debug.WriteLine(" Task result: " + taskResult); ValidateForm(); }
public void CauseValidationToSucceedGivenAValidNumber(int validNumber) { var entity = new ValidatableEntity { MaximumIntOf5Property = validNumber }; Assert.IsTrue(entity.Validate().Count == 0); }
public void CauseValidationToFailGivenNonNumericString(string nonNumericString) { var entity = new ValidatableEntity { MaximumStringOf5Property = nonNumericString }; Assert.IsTrue(entity.Validate().Count > 0); }
public void ReturnValidationResultsWithMemberNameGivenInvalidNumber(int invalidNumber) { var entity = new ValidatableEntity { MaximumIntOf5Property = invalidNumber }; var results = entity.Validate(); // The NumericProperty is causing the failure so that property should be included in the MemberNames... var result = results.FirstOrDefault(r => r.MemberNames.Contains("MaximumIntOf5Property")); Assert.IsTrue(result.IsNotNull()); }