private async void BeUniqueByName_Create_Not_Exists() { Mock <IUnitMeasureRepository> unitMeasureRepository = new Mock <IUnitMeasureRepository>(); unitMeasureRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <UnitMeasure>(null)); var validator = new ApiUnitMeasureRequestModelValidator(unitMeasureRepository.Object); await validator.ValidateCreateAsync(new ApiUnitMeasureRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A"); }
public async void Name_Create_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.ValidateCreateAsync(new ApiUnitMeasureRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 51)); }