public async void Name_Create_length() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Machine())); var validator = new ApiMachineRequestModelValidator(machineRepository.Object); await validator.ValidateCreateAsync(new ApiMachineRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129)); }
private async void BeUniqueByMachineGuid_Create_Not_Exists() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.ByMachineGuid(It.IsAny <Guid>())).Returns(Task.FromResult <Machine>(null)); var validator = new ApiMachineRequestModelValidator(machineRepository.Object); await validator.ValidateCreateAsync(new ApiMachineRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.MachineGuid, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); }
public async void JwtKey_Create_null() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Machine())); var validator = new ApiMachineRequestModelValidator(machineRepository.Object); await validator.ValidateCreateAsync(new ApiMachineRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.JwtKey, null as string); }
private async void BeUniqueByName_Create_Not_Exists() { Mock <IMachineRepository> machineRepository = new Mock <IMachineRepository>(); machineRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Machine>(null)); var validator = new ApiMachineRequestModelValidator(machineRepository.Object); await validator.ValidateCreateAsync(new ApiMachineRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A"); }