public async void Name_Update_length() { Mock <IUnitMeasureRepository> unitMeasureRepository = new Mock <IUnitMeasureRepository>(); unitMeasureRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new UnitMeasure())); var validator = new ApiUnitMeasureRequestModelValidator(unitMeasureRepository.Object); await validator.ValidateUpdateAsync(default(string), new ApiUnitMeasureRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 51)); }
private async void BeUniqueByName_Create_Exists() { Mock <IUnitMeasureRepository> unitMeasureRepository = new Mock <IUnitMeasureRepository>(); unitMeasureRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <UnitMeasure>(new UnitMeasure())); var validator = new ApiUnitMeasureRequestModelValidator(unitMeasureRepository.Object); await validator.ValidateCreateAsync(new ApiUnitMeasureRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, "A"); }
public async void Name_Create_null() { Mock <IUnitMeasureRepository> unitMeasureRepository = new Mock <IUnitMeasureRepository>(); unitMeasureRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new UnitMeasure())); var validator = new ApiUnitMeasureRequestModelValidator(unitMeasureRepository.Object); await validator.ValidateCreateAsync(new ApiUnitMeasureRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, null as string); }